Browse Source

Merge branch 'master' into requirejs

Herbert Vojčík 10 years ago
parent
commit
b2289f4bd7

+ 57 - 57
js/Importer-Exporter.deploy.js

@@ -799,6 +799,61 @@ messageSends: ["stream:", "new"]}),
 smalltalk.ChunkParser.klass);
 
 
+smalltalk.addClass('ExportRecipeInterpreter', smalltalk.Object, [], 'Importer-Exporter');
+smalltalk.addMethod(
+smalltalk.method({
+selector: "interpret:for:on:",
+fn: function (aRecipe,anObject,aStream){
+var self=this;
+var recipeStream;
+return smalltalk.withContext(function($ctx1) { 
+recipeStream=_st(aRecipe)._readStream();
+_st((function(){
+return smalltalk.withContext(function($ctx2) {
+return _st(recipeStream)._atEnd();
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
+return smalltalk.withContext(function($ctx2) {
+return self._interpretStep_for_on_(_st(recipeStream)._next(),anObject,aStream);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"interpret:for:on:",{aRecipe:aRecipe,anObject:anObject,aStream:aStream,recipeStream:recipeStream},smalltalk.ExportRecipeInterpreter)})},
+messageSends: ["readStream", "whileFalse:", "interpretStep:for:on:", "next", "atEnd"]}),
+smalltalk.ExportRecipeInterpreter);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "interpretStep:for:on:",
+fn: function (aRecipeStep,anObject,aStream){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1,$2;
+$1=_st(_st(aRecipeStep)._value()).__eq_eq(aRecipeStep);
+if(smalltalk.assert($1)){
+$2=self._interpretSubRecipe_for_on_(aRecipeStep,anObject,aStream);
+return $2;
+};
+_st(_st(aRecipeStep)._key())._perform_withArguments_(_st(aRecipeStep)._value(),[anObject,aStream]);
+return self}, function($ctx1) {$ctx1.fill(self,"interpretStep:for:on:",{aRecipeStep:aRecipeStep,anObject:anObject,aStream:aStream},smalltalk.ExportRecipeInterpreter)})},
+messageSends: ["ifTrue:", "interpretSubRecipe:for:on:", "==", "value", "perform:withArguments:", "key"]}),
+smalltalk.ExportRecipeInterpreter);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "interpretSubRecipe:for:on:",
+fn: function (aRecipe,anObject,aStream){
+var self=this;
+var selection;
+return smalltalk.withContext(function($ctx1) { 
+selection=_st(_st(_st(aRecipe)._first())._key())._perform_withArguments_(_st(_st(aRecipe)._first())._value(),[anObject]);
+_st(selection)._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
+return self._interpret_for_on_(_st(aRecipe)._allButFirst(),each,aStream);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"interpretSubRecipe:for:on:",{aRecipe:aRecipe,anObject:anObject,aStream:aStream,selection:selection},smalltalk.ExportRecipeInterpreter)})},
+messageSends: ["perform:withArguments:", "value", "first", "key", "do:", "interpret:for:on:", "allButFirst"]}),
+smalltalk.ExportRecipeInterpreter);
+
+
+
 smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
 smalltalk.addMethod(
 smalltalk.method({
@@ -1467,10 +1522,10 @@ smalltalk.method({
 selector: "interpreter",
 fn: function (){
 var self=this;
-function $RecipeInterpreter(){return smalltalk.RecipeInterpreter||(typeof RecipeInterpreter=="undefined"?nil:RecipeInterpreter)}
+function $ExportRecipeInterpreter(){return smalltalk.ExportRecipeInterpreter||(typeof ExportRecipeInterpreter=="undefined"?nil:ExportRecipeInterpreter)}
 return smalltalk.withContext(function($ctx1) { 
 var $1;
-$1=_st($RecipeInterpreter())._new();
+$1=_st($ExportRecipeInterpreter())._new();
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.PluggableExporter)})},
 messageSends: ["new"]}),
@@ -1530,61 +1585,6 @@ return $1;
 messageSends: ["asSet", "sortedClasses"]}),
 smalltalk.PluggableExporter.klass);
 
-
-smalltalk.addClass('RecipeInterpreter', smalltalk.Object, [], 'Importer-Exporter');
-smalltalk.addMethod(
-smalltalk.method({
-selector: "interpret:for:on:",
-fn: function (aRecipe,anObject,aStream){
-var self=this;
-var recipeStream;
-return smalltalk.withContext(function($ctx1) { 
-recipeStream=_st(aRecipe)._readStream();
-_st((function(){
-return smalltalk.withContext(function($ctx2) {
-return _st(recipeStream)._atEnd();
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
-return smalltalk.withContext(function($ctx2) {
-return self._interpretStep_for_on_(_st(recipeStream)._next(),anObject,aStream);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"interpret:for:on:",{aRecipe:aRecipe,anObject:anObject,aStream:aStream,recipeStream:recipeStream},smalltalk.RecipeInterpreter)})},
-messageSends: ["readStream", "whileFalse:", "interpretStep:for:on:", "next", "atEnd"]}),
-smalltalk.RecipeInterpreter);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "interpretStep:for:on:",
-fn: function (aRecipeStep,anObject,aStream){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1,$2;
-$1=_st(_st(aRecipeStep)._value()).__eq_eq(aRecipeStep);
-if(smalltalk.assert($1)){
-$2=self._interpretSubRecipe_for_on_(aRecipeStep,anObject,aStream);
-return $2;
-};
-_st(_st(aRecipeStep)._key())._perform_withArguments_(_st(aRecipeStep)._value(),[anObject,aStream]);
-return self}, function($ctx1) {$ctx1.fill(self,"interpretStep:for:on:",{aRecipeStep:aRecipeStep,anObject:anObject,aStream:aStream},smalltalk.RecipeInterpreter)})},
-messageSends: ["ifTrue:", "interpretSubRecipe:for:on:", "==", "value", "perform:withArguments:", "key"]}),
-smalltalk.RecipeInterpreter);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "interpretSubRecipe:for:on:",
-fn: function (aRecipe,anObject,aStream){
-var self=this;
-var selection;
-return smalltalk.withContext(function($ctx1) { 
-selection=_st(_st(_st(aRecipe)._first())._key())._perform_withArguments_(_st(_st(aRecipe)._first())._value(),[anObject]);
-_st(selection)._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._interpret_for_on_(_st(aRecipe)._allButFirst(),each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"interpretSubRecipe:for:on:",{aRecipe:aRecipe,anObject:anObject,aStream:aStream,selection:selection},smalltalk.RecipeInterpreter)})},
-messageSends: ["perform:withArguments:", "value", "first", "key", "do:", "interpret:for:on:", "allButFirst"]}),
-smalltalk.RecipeInterpreter);
-
-
 smalltalk.addMethod(
 smalltalk.method({
 selector: "amdNamespace",

+ 75 - 75
js/Importer-Exporter.js

@@ -984,6 +984,77 @@ referencedClasses: []
 smalltalk.ChunkParser.klass);
 
 
+smalltalk.addClass('ExportRecipeInterpreter', smalltalk.Object, [], 'Importer-Exporter');
+smalltalk.ExportRecipeInterpreter.comment="I am an interpreter for export recipes.\x0a\x0a## Recipe format\x0a\x0aRecipe is an array, which can contain two kinds of elements:\x0a\x0a - an assocation where the key is the receiver and the value is a two-arguments selector\x0a    In this case, `receiver perform: selector withArguments: { data. stream }` is called.\x0a\x09This essentially defines one step of export process.\x0a\x09The key (eg. receiver) is presumed to be some kind of 'repository' of the exporting methods\x0a\x09that just format appropriate aspect of data into a stream; like a class or a singleton,\x0a\x09so that the recipe itself can be decoupled from data.\x0a\x0a - a subarray, where first element is special and the rest is recursive recipe.\x0a\x0a    `subarray first` must be an association similar to one above,\x0a\x09with key being the 'repository' receiver, but value is one-arg selector.\x0a\x09In this case, `receiver perform: selector withArguments: { data }` should create a collection.\x0a\x09Then, the sub-recipe (`subarray allButFirst`) is applied to every element of a collection, eg.\x0a\x09  collection do: [ :each | self export: each using: sa allButFirst on: stream ]";
+smalltalk.addMethod(
+smalltalk.method({
+selector: "interpret:for:on:",
+category: 'interpreting',
+fn: function (aRecipe,anObject,aStream){
+var self=this;
+var recipeStream;
+return smalltalk.withContext(function($ctx1) { 
+recipeStream=_st(aRecipe)._readStream();
+_st((function(){
+return smalltalk.withContext(function($ctx2) {
+return _st(recipeStream)._atEnd();
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
+return smalltalk.withContext(function($ctx2) {
+return self._interpretStep_for_on_(_st(recipeStream)._next(),anObject,aStream);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"interpret:for:on:",{aRecipe:aRecipe,anObject:anObject,aStream:aStream,recipeStream:recipeStream},smalltalk.ExportRecipeInterpreter)})},
+args: ["aRecipe", "anObject", "aStream"],
+source: "interpret: aRecipe for: anObject on: aStream\x0a\x09| recipeStream |\x0a\x09\x0a\x09recipeStream := aRecipe readStream.\x0a\x09\x0a\x09[ recipeStream atEnd ] whileFalse: [\x0a\x09\x09self \x0a\x09\x09\x09interpretStep: recipeStream next\x0a\x09\x09\x09for: anObject\x0a\x09\x09\x09on: aStream ]",
+messageSends: ["readStream", "whileFalse:", "interpretStep:for:on:", "next", "atEnd"],
+referencedClasses: []
+}),
+smalltalk.ExportRecipeInterpreter);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "interpretStep:for:on:",
+category: 'interpreting',
+fn: function (aRecipeStep,anObject,aStream){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1,$2;
+$1=_st(_st(aRecipeStep)._value()).__eq_eq(aRecipeStep);
+if(smalltalk.assert($1)){
+$2=self._interpretSubRecipe_for_on_(aRecipeStep,anObject,aStream);
+return $2;
+};
+_st(_st(aRecipeStep)._key())._perform_withArguments_(_st(aRecipeStep)._value(),[anObject,aStream]);
+return self}, function($ctx1) {$ctx1.fill(self,"interpretStep:for:on:",{aRecipeStep:aRecipeStep,anObject:anObject,aStream:aStream},smalltalk.ExportRecipeInterpreter)})},
+args: ["aRecipeStep", "anObject", "aStream"],
+source: "interpretStep: aRecipeStep for: anObject on: aStream\x0a\x09aRecipeStep value == aRecipeStep ifTrue: [ \x0a\x09\x09^ self interpretSubRecipe: aRecipeStep for: anObject on: aStream ].\x0a\x09\x09\x09\x0a\x09aRecipeStep key perform: aRecipeStep value withArguments: { anObject. aStream }",
+messageSends: ["ifTrue:", "interpretSubRecipe:for:on:", "==", "value", "perform:withArguments:", "key"],
+referencedClasses: []
+}),
+smalltalk.ExportRecipeInterpreter);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "interpretSubRecipe:for:on:",
+category: 'interpreting',
+fn: function (aRecipe,anObject,aStream){
+var self=this;
+var selection;
+return smalltalk.withContext(function($ctx1) { 
+selection=_st(_st(_st(aRecipe)._first())._key())._perform_withArguments_(_st(_st(aRecipe)._first())._value(),[anObject]);
+_st(selection)._do_((function(each){
+return smalltalk.withContext(function($ctx2) {
+return self._interpret_for_on_(_st(aRecipe)._allButFirst(),each,aStream);
+}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
+return self}, function($ctx1) {$ctx1.fill(self,"interpretSubRecipe:for:on:",{aRecipe:aRecipe,anObject:anObject,aStream:aStream,selection:selection},smalltalk.ExportRecipeInterpreter)})},
+args: ["aRecipe", "anObject", "aStream"],
+source: "interpretSubRecipe: aRecipe for: anObject on: aStream\x0a\x09| selection |\x0a\x09selection := aRecipe first key \x0a\x09\x09perform: aRecipe first value \x0a\x09\x09withArguments: { anObject }.\x0a\x09selection do: [ :each |\x09\x0a\x09\x09self interpret: aRecipe allButFirst for: each on: aStream ]",
+messageSends: ["perform:withArguments:", "value", "first", "key", "do:", "interpret:for:on:", "allButFirst"],
+referencedClasses: []
+}),
+smalltalk.ExportRecipeInterpreter);
+
+
+
 smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
 smalltalk.Importer.comment="I can import Amber code from a string in the chunk format.\x0a\x0a## API\x0a\x0a    Importer new import: aString";
 smalltalk.addMethod(
@@ -1869,16 +1940,16 @@ selector: "interpreter",
 category: 'accessing',
 fn: function (){
 var self=this;
-function $RecipeInterpreter(){return smalltalk.RecipeInterpreter||(typeof RecipeInterpreter=="undefined"?nil:RecipeInterpreter)}
+function $ExportRecipeInterpreter(){return smalltalk.ExportRecipeInterpreter||(typeof ExportRecipeInterpreter=="undefined"?nil:ExportRecipeInterpreter)}
 return smalltalk.withContext(function($ctx1) { 
 var $1;
-$1=_st($RecipeInterpreter())._new();
+$1=_st($ExportRecipeInterpreter())._new();
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.PluggableExporter)})},
 args: [],
-source: "interpreter\x0a\x09^ RecipeInterpreter new",
+source: "interpreter\x0a\x09^ ExportRecipeInterpreter new",
 messageSends: ["new"],
-referencedClasses: ["RecipeInterpreter"]
+referencedClasses: ["ExportRecipeInterpreter"]
 }),
 smalltalk.PluggableExporter);
 
@@ -1956,77 +2027,6 @@ referencedClasses: []
 }),
 smalltalk.PluggableExporter.klass);
 
-
-smalltalk.addClass('RecipeInterpreter', smalltalk.Object, [], 'Importer-Exporter');
-smalltalk.RecipeInterpreter.comment="I am an interpreter for export recipes.\x0a\x0a## Recipe format\x0a\x0aRecipe is an array, which can contain two kinds of elements:\x0a\x0a - an assocation where the key is the receiver and the value is a two-arguments selector\x0a    In this case, `receiver perform: selector withArguments: { data. stream }` is called.\x0a\x09This essentially defines one step of export process.\x0a\x09The key (eg. receiver) is presumed to be some kind of 'repository' of the exporting methods\x0a\x09that just format appropriate aspect of data into a stream; like a class or a singleton,\x0a\x09so that the recipe itself can be decoupled from data.\x0a\x0a - a subarray, where first element is special and the rest is recursive recipe.\x0a\x0a    `subarray first` must be an association similar to one above,\x0a\x09with key being the 'repository' receiver, but value is one-arg selector.\x0a\x09In this case, `receiver perform: selector withArguments: { data }` should create a collection.\x0a\x09Then, the sub-recipe (`subarray allButFirst`) is applied to every element of a collection, eg.\x0a\x09  collection do: [ :each | self export: each using: sa allButFirst on: stream ]";
-smalltalk.addMethod(
-smalltalk.method({
-selector: "interpret:for:on:",
-category: 'interpreting',
-fn: function (aRecipe,anObject,aStream){
-var self=this;
-var recipeStream;
-return smalltalk.withContext(function($ctx1) { 
-recipeStream=_st(aRecipe)._readStream();
-_st((function(){
-return smalltalk.withContext(function($ctx2) {
-return _st(recipeStream)._atEnd();
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
-return smalltalk.withContext(function($ctx2) {
-return self._interpretStep_for_on_(_st(recipeStream)._next(),anObject,aStream);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"interpret:for:on:",{aRecipe:aRecipe,anObject:anObject,aStream:aStream,recipeStream:recipeStream},smalltalk.RecipeInterpreter)})},
-args: ["aRecipe", "anObject", "aStream"],
-source: "interpret: aRecipe for: anObject on: aStream\x0a\x09| recipeStream |\x0a\x09\x0a\x09recipeStream := aRecipe readStream.\x0a\x09\x0a\x09[ recipeStream atEnd ] whileFalse: [\x0a\x09\x09self \x0a\x09\x09\x09interpretStep: recipeStream next\x0a\x09\x09\x09for: anObject\x0a\x09\x09\x09on: aStream ]",
-messageSends: ["readStream", "whileFalse:", "interpretStep:for:on:", "next", "atEnd"],
-referencedClasses: []
-}),
-smalltalk.RecipeInterpreter);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "interpretStep:for:on:",
-category: 'interpreting',
-fn: function (aRecipeStep,anObject,aStream){
-var self=this;
-return smalltalk.withContext(function($ctx1) { 
-var $1,$2;
-$1=_st(_st(aRecipeStep)._value()).__eq_eq(aRecipeStep);
-if(smalltalk.assert($1)){
-$2=self._interpretSubRecipe_for_on_(aRecipeStep,anObject,aStream);
-return $2;
-};
-_st(_st(aRecipeStep)._key())._perform_withArguments_(_st(aRecipeStep)._value(),[anObject,aStream]);
-return self}, function($ctx1) {$ctx1.fill(self,"interpretStep:for:on:",{aRecipeStep:aRecipeStep,anObject:anObject,aStream:aStream},smalltalk.RecipeInterpreter)})},
-args: ["aRecipeStep", "anObject", "aStream"],
-source: "interpretStep: aRecipeStep for: anObject on: aStream\x0a\x09aRecipeStep value == aRecipeStep ifTrue: [ \x0a\x09\x09^ self interpretSubRecipe: aRecipeStep for: anObject on: aStream ].\x0a\x09\x09\x09\x0a\x09aRecipeStep key perform: aRecipeStep value withArguments: { anObject. aStream }",
-messageSends: ["ifTrue:", "interpretSubRecipe:for:on:", "==", "value", "perform:withArguments:", "key"],
-referencedClasses: []
-}),
-smalltalk.RecipeInterpreter);
-
-smalltalk.addMethod(
-smalltalk.method({
-selector: "interpretSubRecipe:for:on:",
-category: 'interpreting',
-fn: function (aRecipe,anObject,aStream){
-var self=this;
-var selection;
-return smalltalk.withContext(function($ctx1) { 
-selection=_st(_st(_st(aRecipe)._first())._key())._perform_withArguments_(_st(_st(aRecipe)._first())._value(),[anObject]);
-_st(selection)._do_((function(each){
-return smalltalk.withContext(function($ctx2) {
-return self._interpret_for_on_(_st(aRecipe)._allButFirst(),each,aStream);
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"interpretSubRecipe:for:on:",{aRecipe:aRecipe,anObject:anObject,aStream:aStream,selection:selection},smalltalk.RecipeInterpreter)})},
-args: ["aRecipe", "anObject", "aStream"],
-source: "interpretSubRecipe: aRecipe for: anObject on: aStream\x0a\x09| selection |\x0a\x09selection := aRecipe first key \x0a\x09\x09perform: aRecipe first value \x0a\x09\x09withArguments: { anObject }.\x0a\x09selection do: [ :each |\x09\x0a\x09\x09self interpret: aRecipe allButFirst for: each on: aStream ]",
-messageSends: ["perform:withArguments:", "value", "first", "key", "do:", "interpret:for:on:", "allButFirst"],
-referencedClasses: []
-}),
-smalltalk.RecipeInterpreter);
-
-
 smalltalk.addMethod(
 smalltalk.method({
 selector: "amdNamespace",

+ 35 - 0
js/Kernel-Objects.deploy.js

@@ -1750,6 +1750,19 @@ return $1;
 messageSends: [",", "printString"]}),
 smalltalk.Number);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "asNumber",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=self;
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"asNumber",{},smalltalk.Number)})},
+messageSends: []}),
+smalltalk.Number);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "asPoint",
@@ -1789,6 +1802,17 @@ return $1;
 messageSends: ["+", "truncated", "*", "next", "new"]}),
 smalltalk.Number);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "ceiling",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+return Math.ceil(self);;
+return self}, function($ctx1) {$ctx1.fill(self,"ceiling",{},smalltalk.Number)})},
+messageSends: []}),
+smalltalk.Number);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "copy",
@@ -1828,6 +1852,17 @@ return $1;
 messageSends: ["=", "\x5c\x5c"]}),
 smalltalk.Number);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "floor",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+return Math.floor(self);;
+return self}, function($ctx1) {$ctx1.fill(self,"floor",{},smalltalk.Number)})},
+messageSends: []}),
+smalltalk.Number);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "identityHash",

+ 50 - 0
js/Kernel-Objects.js

@@ -2449,6 +2449,24 @@ referencedClasses: []
 }),
 smalltalk.Number);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "asNumber",
+category: 'converting',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=self;
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"asNumber",{},smalltalk.Number)})},
+args: [],
+source: "asNumber\x0a\x09^ self",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.Number);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "asPoint",
@@ -2503,6 +2521,22 @@ referencedClasses: ["Random"]
 }),
 smalltalk.Number);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "ceiling",
+category: 'converting',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+return Math.ceil(self);;
+return self}, function($ctx1) {$ctx1.fill(self,"ceiling",{},smalltalk.Number)})},
+args: [],
+source: "ceiling\x0a\x09<return Math.ceil(self);>",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.Number);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "copy",
@@ -2557,6 +2591,22 @@ referencedClasses: []
 }),
 smalltalk.Number);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "floor",
+category: 'converting',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+return Math.floor(self);;
+return self}, function($ctx1) {$ctx1.fill(self,"floor",{},smalltalk.Number)})},
+args: [],
+source: "floor\x0a\x09<return Math.floor(self);>",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.Number);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "identityHash",

+ 50 - 0
js/Kernel-Tests.deploy.js

@@ -1755,6 +1755,19 @@ return self}, function($ctx1) {$ctx1.fill(self,"testAsArray",{},smalltalk.String
 messageSends: ["assert:equals:", "asArray"]}),
 smalltalk.StringTest);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testAsNumber",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_("3"._asNumber(),(3));
+self._assert_equals_("-3"._asNumber(),(-3));
+self._assert_equals_("-1.5"._asNumber(),(-1.5));
+return self}, function($ctx1) {$ctx1.fill(self,"testAsNumber",{},smalltalk.StringTest)})},
+messageSends: ["assert:equals:", "asNumber"]}),
+smalltalk.StringTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testAt",
@@ -2844,6 +2857,30 @@ return self}, function($ctx1) {$ctx1.fill(self,"testArithmetic",{},smalltalk.Num
 messageSends: ["assert:equals:", "+", "-", "/", "*"]}),
 smalltalk.NumberTest);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testAsNumber",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_((3)._asNumber(),(3));
+return self}, function($ctx1) {$ctx1.fill(self,"testAsNumber",{},smalltalk.NumberTest)})},
+messageSends: ["assert:equals:", "asNumber"]}),
+smalltalk.NumberTest);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testCeiling",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_((1.2)._ceiling(),(2));
+self._assert_equals_((-1.2)._ceiling(),(-1));
+self._assert_equals_((1)._ceiling(),(1));
+return self}, function($ctx1) {$ctx1.fill(self,"testCeiling",{},smalltalk.NumberTest)})},
+messageSends: ["assert:equals:", "ceiling"]}),
+smalltalk.NumberTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testComparison",
@@ -2894,6 +2931,19 @@ return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.Numbe
 messageSends: ["assert:", "=", "deny:", "yourself"]}),
 smalltalk.NumberTest);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testFloor",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_((1.2)._floor(),(1));
+self._assert_equals_((-1.2)._floor(),(-2));
+self._assert_equals_((1)._floor(),(1));
+return self}, function($ctx1) {$ctx1.fill(self,"testFloor",{},smalltalk.NumberTest)})},
+messageSends: ["assert:equals:", "floor"]}),
+smalltalk.NumberTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testHexNumbers",

+ 70 - 0
js/Kernel-Tests.js

@@ -2190,6 +2190,24 @@ referencedClasses: []
 }),
 smalltalk.StringTest);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testAsNumber",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_("3"._asNumber(),(3));
+self._assert_equals_("-3"._asNumber(),(-3));
+self._assert_equals_("-1.5"._asNumber(),(-1.5));
+return self}, function($ctx1) {$ctx1.fill(self,"testAsNumber",{},smalltalk.StringTest)})},
+args: [],
+source: "testAsNumber\x0a\x09self assert: '3' asNumber equals: 3.\x0a\x09self assert: '-3' asNumber equals: -3.\x0a\x09self assert: '-1.5' asNumber equals: -1.5.",
+messageSends: ["assert:equals:", "asNumber"],
+referencedClasses: []
+}),
+smalltalk.StringTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testAt",
@@ -3619,6 +3637,40 @@ referencedClasses: []
 }),
 smalltalk.NumberTest);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testAsNumber",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_((3)._asNumber(),(3));
+return self}, function($ctx1) {$ctx1.fill(self,"testAsNumber",{},smalltalk.NumberTest)})},
+args: [],
+source: "testAsNumber\x0a\x09self assert: 3 asNumber equals: 3.",
+messageSends: ["assert:equals:", "asNumber"],
+referencedClasses: []
+}),
+smalltalk.NumberTest);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testCeiling",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_((1.2)._ceiling(),(2));
+self._assert_equals_((-1.2)._ceiling(),(-1));
+self._assert_equals_((1)._ceiling(),(1));
+return self}, function($ctx1) {$ctx1.fill(self,"testCeiling",{},smalltalk.NumberTest)})},
+args: [],
+source: "testCeiling\x0a\x09self assert: 1.2 ceiling equals: 2.\x0a\x09self assert: -1.2 ceiling equals: -1.\x0a\x09self assert: 1.0 ceiling equals: 1.",
+messageSends: ["assert:equals:", "ceiling"],
+referencedClasses: []
+}),
+smalltalk.NumberTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testComparison",
@@ -3684,6 +3736,24 @@ referencedClasses: []
 }),
 smalltalk.NumberTest);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "testFloor",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+self._assert_equals_((1.2)._floor(),(1));
+self._assert_equals_((-1.2)._floor(),(-2));
+self._assert_equals_((1)._floor(),(1));
+return self}, function($ctx1) {$ctx1.fill(self,"testFloor",{},smalltalk.NumberTest)})},
+args: [],
+source: "testFloor\x0a\x09self assert: 1.2 floor equals: 1.\x0a\x09self assert: -1.2 floor equals: -2.\x0a\x09self assert: 1.0 floor equals: 1.",
+messageSends: ["assert:equals:", "floor"],
+referencedClasses: []
+}),
+smalltalk.NumberTest);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "testHexNumbers",

+ 56 - 56
st/Importer-Exporter.st

@@ -474,6 +474,61 @@ on: aStream
 	^self new stream: aStream
 ! !
 
+Object subclass: #ExportRecipeInterpreter
+	instanceVariableNames: ''
+	package: 'Importer-Exporter'!
+!ExportRecipeInterpreter commentStamp!
+I am an interpreter for export recipes.
+
+## Recipe format
+
+Recipe is an array, which can contain two kinds of elements:
+
+ - an assocation where the key is the receiver and the value is a two-arguments selector
+    In this case, `receiver perform: selector withArguments: { data. stream }` is called.
+	This essentially defines one step of export process.
+	The key (eg. receiver) is presumed to be some kind of 'repository' of the exporting methods
+	that just format appropriate aspect of data into a stream; like a class or a singleton,
+	so that the recipe itself can be decoupled from data.
+
+ - a subarray, where first element is special and the rest is recursive recipe.
+
+    `subarray first` must be an association similar to one above,
+	with key being the 'repository' receiver, but value is one-arg selector.
+	In this case, `receiver perform: selector withArguments: { data }` should create a collection.
+	Then, the sub-recipe (`subarray allButFirst`) is applied to every element of a collection, eg.
+	  collection do: [ :each | self export: each using: sa allButFirst on: stream ]!
+
+!ExportRecipeInterpreter methodsFor: 'interpreting'!
+
+interpret: aRecipe for: anObject on: aStream
+	| recipeStream |
+	
+	recipeStream := aRecipe readStream.
+	
+	[ recipeStream atEnd ] whileFalse: [
+		self 
+			interpretStep: recipeStream next
+			for: anObject
+			on: aStream ]
+!
+
+interpretStep: aRecipeStep for: anObject on: aStream
+	aRecipeStep value == aRecipeStep ifTrue: [ 
+		^ self interpretSubRecipe: aRecipeStep for: anObject on: aStream ].
+			
+	aRecipeStep key perform: aRecipeStep value withArguments: { anObject. aStream }
+!
+
+interpretSubRecipe: aRecipe for: anObject on: aStream
+	| selection |
+	selection := aRecipe first key 
+		perform: aRecipe first value 
+		withArguments: { anObject }.
+	selection do: [ :each |	
+		self interpret: aRecipe allButFirst for: each on: aStream ]
+! !
+
 Object subclass: #Importer
 	instanceVariableNames: ''
 	package: 'Importer-Exporter'!
@@ -807,7 +862,7 @@ which exports `aPackage` using the `recipe`
 !PluggableExporter methodsFor: 'accessing'!
 
 interpreter
-	^ RecipeInterpreter new
+	^ ExportRecipeInterpreter new
 !
 
 recipe
@@ -846,61 +901,6 @@ forRecipe: aRecipe
 	^self new recipe: aRecipe; yourself
 ! !
 
-Object subclass: #RecipeInterpreter
-	instanceVariableNames: ''
-	package: 'Importer-Exporter'!
-!RecipeInterpreter commentStamp!
-I am an interpreter for export recipes.
-
-## Recipe format
-
-Recipe is an array, which can contain two kinds of elements:
-
- - an assocation where the key is the receiver and the value is a two-arguments selector
-    In this case, `receiver perform: selector withArguments: { data. stream }` is called.
-	This essentially defines one step of export process.
-	The key (eg. receiver) is presumed to be some kind of 'repository' of the exporting methods
-	that just format appropriate aspect of data into a stream; like a class or a singleton,
-	so that the recipe itself can be decoupled from data.
-
- - a subarray, where first element is special and the rest is recursive recipe.
-
-    `subarray first` must be an association similar to one above,
-	with key being the 'repository' receiver, but value is one-arg selector.
-	In this case, `receiver perform: selector withArguments: { data }` should create a collection.
-	Then, the sub-recipe (`subarray allButFirst`) is applied to every element of a collection, eg.
-	  collection do: [ :each | self export: each using: sa allButFirst on: stream ]!
-
-!RecipeInterpreter methodsFor: 'interpreting'!
-
-interpret: aRecipe for: anObject on: aStream
-	| recipeStream |
-	
-	recipeStream := aRecipe readStream.
-	
-	[ recipeStream atEnd ] whileFalse: [
-		self 
-			interpretStep: recipeStream next
-			for: anObject
-			on: aStream ]
-!
-
-interpretStep: aRecipeStep for: anObject on: aStream
-	aRecipeStep value == aRecipeStep ifTrue: [ 
-		^ self interpretSubRecipe: aRecipeStep for: anObject on: aStream ].
-			
-	aRecipeStep key perform: aRecipeStep value withArguments: { anObject. aStream }
-!
-
-interpretSubRecipe: aRecipe for: anObject on: aStream
-	| selection |
-	selection := aRecipe first key 
-		perform: aRecipe first value 
-		withArguments: { anObject }.
-	selection do: [ :each |	
-		self interpret: aRecipe allButFirst for: each on: aStream ]
-! !
-
 !Package methodsFor: '*Importer-Exporter'!
 
 amdNamespace

+ 12 - 0
st/Kernel-Objects.st

@@ -832,6 +832,10 @@ asJavascript
 	^'(', self printString, ')'
 !
 
+asNumber
+	^ self
+!
+
 asPoint
 	^Point x: self y: self
 !
@@ -844,6 +848,14 @@ atRandom
 	^(Random new next * self) truncated + 1
 !
 
+ceiling
+	<return Math.ceil(self);>
+!
+
+floor
+	<return Math.floor(self);>
+!
+
 rounded
 	<return Math.round(self);>
 !

+ 22 - 0
st/Kernel-Tests.st

@@ -840,6 +840,12 @@ testAsArray
 	self assert: 'hello' asArray equals: #('h' 'e' 'l' 'l' 'o').
 !
 
+testAsNumber
+	self assert: '3' asNumber equals: 3.
+	self assert: '-3' asNumber equals: -3.
+	self assert: '-1.5' asNumber equals: -1.5.
+!
+
 testAt
 	self assert: ('hello' at: 1) equals: 'h'.
 	self assert: ('hello' at: 5) equals: 'o'.
@@ -1356,6 +1362,16 @@ testArithmetic
 	self assert: 1 + (2 * 3) equals: 7
 !
 
+testAsNumber
+	self assert: 3 asNumber equals: 3.
+!
+
+testCeiling
+	self assert: 1.2 ceiling equals: 2.
+	self assert: -1.2 ceiling equals: -1.
+	self assert: 1.0 ceiling equals: 1.
+!
+
 testComparison
 
 	self assert: 3 > 2.
@@ -1390,6 +1406,12 @@ testEquality
 	self deny: 0 = ''
 !
 
+testFloor
+	self assert: 1.2 floor equals: 1.
+	self assert: -1.2 floor equals: -2.
+	self assert: 1.0 floor equals: 1.
+!
+
 testHexNumbers
 
 	self assert: 16r9 equals: 9.

+ 2 - 1
support/boot.js

@@ -812,9 +812,10 @@ function RuntimeBrik(brikz, st) {
 			this.lookupClass = lookupClass;
 		};
 
-		SmalltalkMethodContext.prototype.fillBlock = function(locals, ctx) {
+		SmalltalkMethodContext.prototype.fillBlock = function(locals, ctx, index) {
 			this.locals        = locals || {};
 			this.outerContext  = ctx;
+			this.index         = index || 0;
 		};
 
 		SmalltalkMethodContext.prototype.init = function() {