Просмотр исходного кода

Refactored all methods inluding both temps and inlined JS

Nicolas Petton 11 лет назад
Родитель
Сommit
74ce81b7f1
9 измененных файлов с 710 добавлено и 437 удалено
  1. 12 0
      js/Canvas.deploy.js
  2. 17 0
      js/Canvas.js
  3. 82 144
      js/Kernel-Objects.deploy.js
  4. 111 183
      js/Kernel-Objects.js
  5. 181 6
      js/Kernel-Tests.deploy.js
  6. 177 2
      js/Kernel-Tests.js
  7. 6 0
      st/Canvas.st
  8. 51 95
      st/Kernel-Objects.st
  9. 73 7
      st/Kernel-Tests.st

+ 12 - 0
js/Canvas.deploy.js

@@ -2484,3 +2484,15 @@ return self}, self, "asJQuery", [], smalltalk.String)}
 }),
 smalltalk.String);
 
+smalltalk.addMethod(
+"_asJQuery",
+smalltalk.method({
+selector: "asJQuery",
+fn: function (){
+var self=this;
+return jQuery(self['@jsObject']);
+;
+return self}
+}),
+smalltalk.JSObjectProxy);
+

+ 17 - 0
js/Canvas.js

@@ -3480,3 +3480,20 @@ referencedClasses: []
 }),
 smalltalk.String);
 
+smalltalk.addMethod(
+"_asJQuery",
+smalltalk.method({
+selector: "asJQuery",
+category: '*Canvas',
+fn: function (){
+var self=this;
+return jQuery(self['@jsObject']);
+;
+return self},
+args: [],
+source: "asJQuery\x0a    <return jQuery(self['@jsObject'])>",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.JSObjectProxy);
+

+ 82 - 144
js/Kernel-Objects.deploy.js

@@ -332,13 +332,11 @@ smalltalk.addMethod(
 "_instVarAt_",
 smalltalk.method({
 selector: "instVarAt:",
-fn: function (aSymbol) {
-    var self = this;
-    var varname;
-    varname = smalltalk.send(aSymbol, "_asString", []);
-    return self["@" + varname];
-    return self;
-}
+fn: function (aSymbol){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self['@'+aSymbol._asString()];
+;
+return self}, self, "instVarAt:", [aSymbol], smalltalk.Object)}
 }),
 smalltalk.Object);
 
@@ -346,13 +344,11 @@ smalltalk.addMethod(
 "_instVarAt_put_",
 smalltalk.method({
 selector: "instVarAt:put:",
-fn: function (aSymbol, anObject) {
-    var self = this;
-    var varname;
-    varname = smalltalk.send(aSymbol, "_asString", []);
-    self["@" + varname] = anObject;
-    return self;
-}
+fn: function (aSymbol,anObject){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
self['@' + aSymbol._asString()] = anObject;
+;
+return self}, self, "instVarAt:put:", [aSymbol,anObject], smalltalk.Object)}
 }),
 smalltalk.Object);
 
@@ -507,13 +503,11 @@ smalltalk.addMethod(
 "_perform_withArguments_",
 smalltalk.method({
 selector: "perform:withArguments:",
-fn: function (aSymbol, aCollection) {
-    var self = this;
-    var selector;
-    selector = smalltalk.send(aSymbol, "_asSelector", []);
-    return smalltalk.send(self, selector, aCollection);
-    return self;
-}
+fn: function (aSymbol,aCollection){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return smalltalk.send(self, aSymbol._asSelector(), aCollection);
+;
+return self}, self, "perform:withArguments:", [aSymbol,aCollection], smalltalk.Object)}
 }),
 smalltalk.Object);
 
@@ -1628,17 +1622,29 @@ smalltalk.Date.klass);
 
 
 smalltalk.addClass('JSObjectProxy', smalltalk.Object, ['jsObject'], 'Kernel-Objects');
+smalltalk.addMethod(
+"_addObjectVariablesTo_",
+smalltalk.method({
+selector: "addObjectVariablesTo:",
+fn: function (aDictionary){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
for(var i in self['@jsObject']) {
+		aDictionary._at_put_(i, self['@jsObject'][i]);
+	};
+;
+return self}, self, "addObjectVariablesTo:", [aDictionary], smalltalk.JSObjectProxy)}
+}),
+smalltalk.JSObjectProxy);
+
 smalltalk.addMethod(
 "_at_",
 smalltalk.method({
 selector: "at:",
-fn: function (aSymbol) {
-    var self = this;
-    var attr;
-    attr = smalltalk.send(aSymbol, "_asString", []);
-    return self['@jsObject'][attr];
-    return self;
-}
+fn: function (aSymbol){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self['@jsObject'][aSymbol._asString()];
+;
+return self}, self, "at:", [aSymbol], smalltalk.JSObjectProxy)}
 }),
 smalltalk.JSObjectProxy);
 
@@ -1646,13 +1652,11 @@ smalltalk.addMethod(
 "_at_put_",
 smalltalk.method({
 selector: "at:put:",
-fn: function (aSymbol, anObject) {
-    var self = this;
-    var attr;
-    attr = smalltalk.send(aSymbol, "_asString", []);
-    self['@jsObject'][attr] = anObject;
-    return self;
-}
+fn: function (aSymbol,anObject){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
self['@jsObject'][aSymbol._asString()] = anObject;
+;
+return self}, self, "at:put:", [aSymbol,anObject], smalltalk.JSObjectProxy)}
 }),
 smalltalk.JSObjectProxy);
 
@@ -1660,22 +1664,18 @@ smalltalk.addMethod(
 "_doesNotUnderstand_",
 smalltalk.method({
 selector: "doesNotUnderstand:",
-fn: function (aMessage) {
-    var self = this;
-    var obj;
-    var selector;
-    var jsSelector;
-    var arguments;
-    obj = smalltalk.send(self, "_jsObject", []);
-    selector = smalltalk.send(aMessage, "_selector", []);
-    jsSelector = smalltalk.send(selector, "_asJavaScriptSelector", []);
-    arguments = smalltalk.send(aMessage, "_arguments", []);
-    if (obj[jsSelector] != undefined) {
-        return smalltalk.send(obj, jsSelector, arguments);
-    }
-    smalltalk.send(self, "_doesNotUnderstand_", [aMessage], smalltalk.Object);
-    return self;
-}
+fn: function (aMessage){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+    	var jsSelector = aMessage._selector()._asJavaScriptSelector();
+        var object = self._jsObject();
+    	if(jsSelector in object) {
+        	return smalltalk.send(object, jsSelector, aMessage._arguments());
+        }
+    ;
+;
+smalltalk.Object.fn.prototype._doesNotUnderstand_.apply(_st(self), [aMessage]);
+return self}, self, "doesNotUnderstand:", [aMessage], smalltalk.JSObjectProxy)}
 }),
 smalltalk.JSObjectProxy);
 
@@ -1683,18 +1683,15 @@ smalltalk.addMethod(
 "_inspectOn_",
 smalltalk.method({
 selector: "inspectOn:",
-fn: function (anInspector) {
-    var self = this;
-    var variables;
-    variables = smalltalk.send(smalltalk.Dictionary || Dictionary, "_new", []);
-    smalltalk.send(variables, "_at_put_", ["#self", smalltalk.send(self, "_jsObject", [])]);
-    smalltalk.send(anInspector, "_setLabel_", [smalltalk.send(self, "_printString", [])]);
-    for (var i in self['@jsObject']) {
-        variables._at_put_(i, self['@jsObject'][i]);
-    }
-    smalltalk.send(anInspector, "_setVariables_", [variables]);
-    return self;
-}
+fn: function (anInspector){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
$ctx1.variables=nil;
+$ctx1.variables=_st((smalltalk.Dictionary || Dictionary))._new();
+_st($ctx1.variables)._at_put_("#self",_st(self)._jsObject());
+_st(anInspector)._setLabel_(_st(self)._printString());
+_st(self)._addObjectVariablesTo_($ctx1.variables);
+_st(anInspector)._setVariables_($ctx1.variables);
+return self}, self, "inspectOn:", [anInspector], smalltalk.JSObjectProxy)}
 }),
 smalltalk.JSObjectProxy);
 
@@ -2320,18 +2317,17 @@ smalltalk.addMethod(
 "_truncated",
 smalltalk.method({
 selector: "truncated",
-fn: function () {
-    var self = this;
-    var $1;
-    var result;
-    $1 = smalltalk.send(self, "__gt_eq", [0]);
-    if (smalltalk.assert($1)) {
-        result = Math.floor(self);
-    } else {
-        result = Math.floor(self * -1) * -1;
-    }
-    return result;
-}
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+    	if(self >= 0) {
+        	return Math.floor(self);
+        } else {
+        	return Math.floor(self * (-1)) * (-1);
+        };
+    ;
+;
+return self}, self, "truncated", [], smalltalk.Number)}
 }),
 smalltalk.Number);
 
@@ -2588,21 +2584,6 @@ fn: function () {
 }),
 smalltalk.Package);
 
-smalltalk.addMethod(
-"_properties_",
-smalltalk.method({
-selector: "properties:",
-fn: function (aDict) {
-    var self = this;
-    var object;
-    object = {};
-    smalltalk.send(aDict, "_keysAndValuesDo_", [function (key, value) {return object[key] = value;}]);
-    return self.properties = object;
-    return self;
-}
-}),
-smalltalk.Package);
-
 smalltalk.addMethod(
 "_propertiesAsJSON",
 smalltalk.method({
@@ -3089,26 +3070,11 @@ smalltalk.addMethod(
 "_createPackage_",
 smalltalk.method({
 selector: "createPackage:",
-fn: function (packageName) {
-    var self = this;
-    return smalltalk.addPackage(packageName, nil);
-    return self;
-}
-}),
-smalltalk.Smalltalk);
-
-smalltalk.addMethod(
-"_createPackage_properties_",
-smalltalk.method({
-selector: "createPackage:properties:",
-fn: function (packageName, aDict) {
-    var self = this;
-    var object;
-    object = {};
-    smalltalk.send(aDict, "_keysAndValuesDo_", [function (key, value) {return object[key] = value;}]);
-    return smalltalk.addPackage(packageName, object);
-    return self;
-}
+fn: function (packageName){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return smalltalk.addPackage(packageName);
+;
+return self}, self, "createPackage:", [packageName], smalltalk.Smalltalk)}
 }),
 smalltalk.Smalltalk);
 
@@ -3191,26 +3157,12 @@ smalltalk.addMethod(
 "_parseError_parsing_",
 smalltalk.method({
 selector: "parseError:parsing:",
-fn: function (anException, aString) {
-    var self = this;
-    var $1;
-    var row;
-    var col;
-    var message;
-    var lines;
-    var badLine;
-    var code;
-    row = anException.line;
-    col = anException.column;
-    message = anException.message;
-    lines = smalltalk.send(aString, "_lines", []);
-    badLine = smalltalk.send(lines, "_at_", [row]);
-    badLine = smalltalk.send(smalltalk.send(smalltalk.send(badLine, "_copyFrom_to_", [1, smalltalk.send(col, "__minus", [1])]), "__comma", [" ===>"]), "__comma", [smalltalk.send(badLine, "_copyFrom_to_", [col, smalltalk.send(badLine, "_size", [])])]);
-    smalltalk.send(lines, "_at_put_", [row, badLine]);
-    code = smalltalk.send(smalltalk.String || String, "_streamContents_", [function (s) {return smalltalk.send(lines, "_withIndexDo_", [function (l, i) {return smalltalk.send(s, "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(i, "_asString", []), "__comma", [": "]), "__comma", [l]), "__comma", [smalltalk.send(smalltalk.String || String, "_lf", [])])]);}]);}]);
-    $1 = smalltalk.send(smalltalk.send(smalltalk.ParseError || ParseError, "_new", []), "_messageText_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("Parse error on line ", "__comma", [row]), "__comma", [" column "]), "__comma", [col]), "__comma", [" : "]), "__comma", [message]), "__comma", [" Below is code with line numbers and ===> marker inserted:"]), "__comma", [smalltalk.send(smalltalk.String || String, "_lf", [])]), "__comma", [code])]);
-    return $1;
-}
+fn: function (anException,aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(_st((smalltalk.ParseError || ParseError))._new())._messageText_(_st(_st(_st(_st(_st("Parse error on line ").__comma(_st(anException)._basicAt_("line"))).__comma(" column ")).__comma(_st(anException)._basicAt_("column"))).__comma(" : Unexpected character ")).__comma(_st(anException)._basicAt_("found")));
+return $1;
+}, self, "parseError:parsing:", [anException,aString], smalltalk.Smalltalk)}
 }),
 smalltalk.Smalltalk);
 
@@ -3309,20 +3261,6 @@ fn: function () {
 }),
 smalltalk.Smalltalk);
 
-smalltalk.addMethod(
-"_send_to_arguments_",
-smalltalk.method({
-selector: "send:to:arguments:",
-fn: function (aSelector, anObject, aCollection) {
-    var self = this;
-    var selector;
-    selector = smalltalk.send(smalltalk.send(aSelector, "_asString", []), "_asSelector", []);
-    return self.send(anObject, selector, aCollection);
-    return self;
-}
-}),
-smalltalk.Smalltalk);
-
 
 smalltalk.Smalltalk.klass.iVarNames = ['current'];
 smalltalk.addMethod(

+ 111 - 183
js/Kernel-Objects.js

@@ -459,16 +459,14 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "instVarAt:",
 category: 'accessing',
-fn: function (aSymbol) {
-    var self = this;
-    var varname;
-    varname = smalltalk.send(aSymbol, "_asString", []);
-    return self["@" + varname];
-    return self;
-},
+fn: function (aSymbol){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self['@'+aSymbol._asString()];
+;
+return self}, self, "instVarAt:", [aSymbol], smalltalk.Object)},
 args: ["aSymbol"],
-source: "instVarAt: aSymbol\x0a\x09| varname |\x0a\x09varname := aSymbol asString.\x0a\x09<return self['@'+varname]>",
-messageSends: ["asString"],
+source: "instVarAt: aSymbol\x0a\x09<return self['@'+aSymbol._asString()]>",
+messageSends: [],
 referencedClasses: []
 }),
 smalltalk.Object);
@@ -478,16 +476,14 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "instVarAt:put:",
 category: 'accessing',
-fn: function (aSymbol, anObject) {
-    var self = this;
-    var varname;
-    varname = smalltalk.send(aSymbol, "_asString", []);
-    self["@" + varname] = anObject;
-    return self;
-},
+fn: function (aSymbol,anObject){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
self['@' + aSymbol._asString()] = anObject;
+;
+return self}, self, "instVarAt:put:", [aSymbol,anObject], smalltalk.Object)},
 args: ["aSymbol", "anObject"],
-source: "instVarAt: aSymbol put: anObject\x0a\x09| varname |\x0a\x09varname := aSymbol asString.\x0a\x09<self['@' + varname] = anObject>",
-messageSends: ["asString"],
+source: "instVarAt: aSymbol put: anObject\x0a\x09<self['@' + aSymbol._asString()] = anObject>",
+messageSends: [],
 referencedClasses: []
 }),
 smalltalk.Object);
@@ -704,16 +700,14 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "perform:withArguments:",
 category: 'message handling',
-fn: function (aSymbol, aCollection) {
-    var self = this;
-    var selector;
-    selector = smalltalk.send(aSymbol, "_asSelector", []);
-    return smalltalk.send(self, selector, aCollection);
-    return self;
-},
+fn: function (aSymbol,aCollection){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return smalltalk.send(self, aSymbol._asSelector(), aCollection);
+;
+return self}, self, "perform:withArguments:", [aSymbol,aCollection], smalltalk.Object)},
 args: ["aSymbol", "aCollection"],
-source: "perform: aSymbol withArguments: aCollection\x0a\x09| selector |\x0a\x09selector := aSymbol asSelector.\x0a\x09<return smalltalk.send(self, selector, aCollection)>",
-messageSends: ["asSelector"],
+source: "perform: aSymbol withArguments: aCollection\x0a\x09<return smalltalk.send(self, aSymbol._asSelector(), aCollection)>",
+messageSends: [],
 referencedClasses: []
 }),
 smalltalk.Object);
@@ -2258,21 +2252,38 @@ smalltalk.Date.klass);
 
 smalltalk.addClass('JSObjectProxy', smalltalk.Object, ['jsObject'], 'Kernel-Objects');
 smalltalk.JSObjectProxy.comment="JSObjectProxy handles sending messages to JavaScript object, therefore accessing JavaScript objects from Amber is transparent.\x0aJSOjbectProxy makes intensive use of `#doesNotUnderstand:`.\x0a\x0a## Examples\x0a\x0aJSObjectProxy objects are instanciated by Amber when a Smalltalk message is sent to a JavaScript object.\x0a\x0a    window alert: 'hello world'.\x0a    window inspect.\x0a    (window jQuery: 'body') append: 'hello world'\x0a\x0aSmalltalk messages sends are converted to JavaScript function calls or object property access _(in this order)_. If n one of them match, a `MessageNotUnderstood` error will be thrown. \x0a\x0a## Message conversion rules\x0a\x0a- `someUser name` becomes  `someUser.name`\x0a- `someUser name: 'John'` becomes `someUser name = \x22John\x22`\x0a- `console log: 'hello world'` becomes `console.log('hello world')`\x0a- `(window jQuery: 'foo') css: 'background' color: 'red'` becomes `window.jQuery('foo').css('background', 'red')`\x0a\x0a__Note:__ For keyword-based messages, only the first keyword is kept: `window foo: 1 bar: 2` is equivalent to `window foo: 1 baz: 2`."
+smalltalk.addMethod(
+"_addObjectVariablesTo_",
+smalltalk.method({
+selector: "addObjectVariablesTo:",
+category: 'proxy',
+fn: function (aDictionary){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
for(var i in self['@jsObject']) {
+		aDictionary._at_put_(i, self['@jsObject'][i]);
+	};
+;
+return self}, self, "addObjectVariablesTo:", [aDictionary], smalltalk.JSObjectProxy)},
+args: ["aDictionary"],
+source: "addObjectVariablesTo: aDictionary\x0a\x09<for(var i in self['@jsObject']) {\x0a\x09\x09aDictionary._at_put_(i, self['@jsObject'][i]);\x0a\x09}>.",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.JSObjectProxy);
+
 smalltalk.addMethod(
 "_at_",
 smalltalk.method({
 selector: "at:",
 category: 'accessing',
-fn: function (aSymbol) {
-    var self = this;
-    var attr;
-    attr = smalltalk.send(aSymbol, "_asString", []);
-    return self['@jsObject'][attr];
-    return self;
-},
+fn: function (aSymbol){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return self['@jsObject'][aSymbol._asString()];
+;
+return self}, self, "at:", [aSymbol], smalltalk.JSObjectProxy)},
 args: ["aSymbol"],
-source: "at: aSymbol\x0a\x09| attr |\x0a\x09attr := aSymbol asString.\x0a\x09<return self['@jsObject'][attr]>",
-messageSends: ["asString"],
+source: "at: aSymbol\x0a\x09<return self['@jsObject'][aSymbol._asString()]>",
+messageSends: [],
 referencedClasses: []
 }),
 smalltalk.JSObjectProxy);
@@ -2282,16 +2293,14 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "at:put:",
 category: 'accessing',
-fn: function (aSymbol, anObject) {
-    var self = this;
-    var attr;
-    attr = smalltalk.send(aSymbol, "_asString", []);
-    self['@jsObject'][attr] = anObject;
-    return self;
-},
+fn: function (aSymbol,anObject){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
self['@jsObject'][aSymbol._asString()] = anObject;
+;
+return self}, self, "at:put:", [aSymbol,anObject], smalltalk.JSObjectProxy)},
 args: ["aSymbol", "anObject"],
-source: "at: aSymbol put: anObject\x0a\x09| attr |\x0a\x09attr := aSymbol asString.\x0a\x09<self['@jsObject'][attr] = anObject>",
-messageSends: ["asString"],
+source: "at: aSymbol put: anObject\x0a\x09<self['@jsObject'][aSymbol._asString()] = anObject>",
+messageSends: [],
 referencedClasses: []
 }),
 smalltalk.JSObjectProxy);
@@ -2301,25 +2310,21 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "doesNotUnderstand:",
 category: 'proxy',
-fn: function (aMessage) {
-    var self = this;
-    var obj;
-    var selector;
-    var jsSelector;
-    var arguments;
-    obj = smalltalk.send(self, "_jsObject", []);
-    selector = smalltalk.send(aMessage, "_selector", []);
-    jsSelector = smalltalk.send(selector, "_asJavaScriptSelector", []);
-    arguments = smalltalk.send(aMessage, "_arguments", []);
-    if (obj[jsSelector] != undefined) {
-        return smalltalk.send(obj, jsSelector, arguments);
-    }
-    smalltalk.send(self, "_doesNotUnderstand_", [aMessage], smalltalk.Object);
-    return self;
-},
+fn: function (aMessage){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+    	var jsSelector = aMessage._selector()._asJavaScriptSelector();
+        var object = self._jsObject();
+    	if(jsSelector in object) {
+        	return smalltalk.send(object, jsSelector, aMessage._arguments());
+        }
+    ;
+;
+smalltalk.Object.fn.prototype._doesNotUnderstand_.apply(_st(self), [aMessage]);
+return self}, self, "doesNotUnderstand:", [aMessage], smalltalk.JSObjectProxy)},
 args: ["aMessage"],
-source: "doesNotUnderstand: aMessage\x0a\x09| obj selector jsSelector arguments |\x0a\x09obj := self jsObject.\x0a\x09selector := aMessage selector.\x0a\x09jsSelector := selector asJavaScriptSelector.\x0a\x09arguments := aMessage arguments.\x0a\x09<if(obj[jsSelector] != undefined) {return smalltalk.send(obj, jsSelector, arguments)}>.\x0a\x09super doesNotUnderstand: aMessage",
-messageSends: ["jsObject", "selector", "asJavaScriptSelector", "arguments", "doesNotUnderstand:"],
+source: "doesNotUnderstand: aMessage\x0a\x09<\x0a    \x09var jsSelector = aMessage._selector()._asJavaScriptSelector();\x0a        var object = self._jsObject();\x0a    \x09if(jsSelector in object) {\x0a        \x09return smalltalk.send(object, jsSelector, aMessage._arguments());\x0a        }\x0a    >.\x0a    \x0a\x09super doesNotUnderstand: aMessage",
+messageSends: ["doesNotUnderstand:"],
 referencedClasses: []
 }),
 smalltalk.JSObjectProxy);
@@ -2329,21 +2334,18 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "inspectOn:",
 category: 'proxy',
-fn: function (anInspector) {
-    var self = this;
-    var variables;
-    variables = smalltalk.send(smalltalk.Dictionary || Dictionary, "_new", []);
-    smalltalk.send(variables, "_at_put_", ["#self", smalltalk.send(self, "_jsObject", [])]);
-    smalltalk.send(anInspector, "_setLabel_", [smalltalk.send(self, "_printString", [])]);
-    for (var i in self['@jsObject']) {
-        variables._at_put_(i, self['@jsObject'][i]);
-    }
-    smalltalk.send(anInspector, "_setVariables_", [variables]);
-    return self;
-},
+fn: function (anInspector){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
$ctx1.variables=nil;
+$ctx1.variables=_st((smalltalk.Dictionary || Dictionary))._new();
+_st($ctx1.variables)._at_put_("#self",_st(self)._jsObject());
+_st(anInspector)._setLabel_(_st(self)._printString());
+_st(self)._addObjectVariablesTo_($ctx1.variables);
+_st(anInspector)._setVariables_($ctx1.variables);
+return self}, self, "inspectOn:", [anInspector], smalltalk.JSObjectProxy)},
 args: ["anInspector"],
-source: "inspectOn: anInspector\x0a\x09| variables |\x0a\x09variables := Dictionary new.\x0a\x09variables at: '#self' put: self jsObject.\x0a\x09anInspector setLabel: self printString.\x0a\x09<for(var i in self['@jsObject']) {\x0a\x09\x09variables._at_put_(i, self['@jsObject'][i]);\x0a\x09}>.\x0a\x09anInspector setVariables: variables",
-messageSends: ["new", "at:put:", "jsObject", "setLabel:", "printString", "setVariables:"],
+source: "inspectOn: anInspector\x0a\x09| variables |\x0a\x09variables := Dictionary new.\x0a\x09variables at: '#self' put: self jsObject.\x0a\x09anInspector setLabel: self printString.\x0a\x09self addObjectVariablesTo: variables.\x0a\x09anInspector setVariables: variables",
+messageSends: ["new", "at:put:", "jsObject", "setLabel:", "printString", "addObjectVariablesTo:", "setVariables:"],
 referencedClasses: ["Dictionary"]
 }),
 smalltalk.JSObjectProxy);
@@ -3202,21 +3204,20 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "truncated",
 category: 'converting',
-fn: function () {
-    var self = this;
-    var $1;
-    var result;
-    $1 = smalltalk.send(self, "__gt_eq", [0]);
-    if (smalltalk.assert($1)) {
-        result = Math.floor(self);
-    } else {
-        result = Math.floor(self * -1) * -1;
-    }
-    return result;
-},
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+    	if(self >= 0) {
+        	return Math.floor(self);
+        } else {
+        	return Math.floor(self * (-1)) * (-1);
+        };
+    ;
+;
+return self}, self, "truncated", [], smalltalk.Number)},
 args: [],
-source: "truncated\x0a|result|\x0a\x0a    self >= 0 \x0a        ifTrue: [<result = Math.floor(self);>]\x0a        ifFalse: [<result = (Math.floor(self * (-1)) * (-1));>].\x0a\x0a    ^ result",
-messageSends: ["ifTrue:ifFalse:", ">="],
+source: "truncated\x0a\x09<\x0a    \x09if(self >>= 0) {\x0a        \x09return Math.floor(self);\x0a        } else {\x0a        \x09return Math.floor(self * (-1)) * (-1);\x0a        };\x0a    >",
+messageSends: [],
 referencedClasses: []
 }),
 smalltalk.Number);
@@ -3570,26 +3571,6 @@ referencedClasses: ["Smalltalk"]
 }),
 smalltalk.Package);
 
-smalltalk.addMethod(
-"_properties_",
-smalltalk.method({
-selector: "properties:",
-category: 'accessing',
-fn: function (aDict) {
-    var self = this;
-    var object;
-    object = {};
-    smalltalk.send(aDict, "_keysAndValuesDo_", [function (key, value) {return object[key] = value;}]);
-    return self.properties = object;
-    return self;
-},
-args: ["aDict"],
-source: "properties: aDict\x0a\x09\x22We store it as a javascript object.\x22\x0a\x09\x0a\x09| object |\x0a\x09<object = {};>.\x0a\x09aDict keysAndValuesDo: [:key :value |\x0a\x09\x09<object[key] = value>.\x0a\x09].\x0a\x09<return self.properties = object>",
-messageSends: ["keysAndValuesDo:"],
-referencedClasses: []
-}),
-smalltalk.Package);
-
 smalltalk.addMethod(
 "_propertiesAsJSON",
 smalltalk.method({
@@ -4254,44 +4235,24 @@ smalltalk.addMethod(
 "_createPackage_",
 smalltalk.method({
 selector: "createPackage:",
-category: 'private',
-fn: function (packageName) {
-    var self = this;
-    return smalltalk.addPackage(packageName, nil);
-    return self;
-},
+category: 'packages',
+fn: function (packageName){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return smalltalk.addPackage(packageName);
+;
+return self}, self, "createPackage:", [packageName], smalltalk.Smalltalk)},
 args: ["packageName"],
-source: "createPackage: packageName\x0a\x09\x22Create and bind a new package with given name and return it.\x22\x0a\x0a      <return smalltalk.addPackage(packageName, nil)>",
+source: "createPackage: packageName\x0a\x09\x22Create and bind a new package with given name and return it.\x22\x0a       <return smalltalk.addPackage(packageName)>",
 messageSends: [],
 referencedClasses: []
 }),
 smalltalk.Smalltalk);
 
-smalltalk.addMethod(
-"_createPackage_properties_",
-smalltalk.method({
-selector: "createPackage:properties:",
-category: 'private',
-fn: function (packageName, aDict) {
-    var self = this;
-    var object;
-    object = {};
-    smalltalk.send(aDict, "_keysAndValuesDo_", [function (key, value) {return object[key] = value;}]);
-    return smalltalk.addPackage(packageName, object);
-    return self;
-},
-args: ["packageName", "aDict"],
-source: "createPackage: packageName properties: aDict\x0a\x09\x22Create and bind a new package with given name and return it.\x22\x0a\x0a\x09| object |\x0a\x09<object = {};>.\x0a\x09aDict keysAndValuesDo: [:key :value |\x0a\x09\x09<object[key] = value>.\x0a\x09].\x0a       <return smalltalk.addPackage(packageName, object)>",
-messageSends: ["keysAndValuesDo:"],
-referencedClasses: []
-}),
-smalltalk.Smalltalk);
-
 smalltalk.addMethod(
 "_deleteClass_",
 smalltalk.method({
 selector: "deleteClass:",
-category: 'private',
+category: 'classes',
 fn: function (aClass) {
     var self = this;
     self.removeClass(aClass);
@@ -4308,7 +4269,7 @@ smalltalk.addMethod(
 "_deletePackage_",
 smalltalk.method({
 selector: "deletePackage:",
-category: 'private',
+category: 'packages',
 fn: function (packageName) {
     var self = this;
     delete smalltalk.packages[packageName];
@@ -4396,31 +4357,17 @@ smalltalk.addMethod(
 "_parseError_parsing_",
 smalltalk.method({
 selector: "parseError:parsing:",
-category: 'accessing',
-fn: function (anException, aString) {
-    var self = this;
-    var $1;
-    var row;
-    var col;
-    var message;
-    var lines;
-    var badLine;
-    var code;
-    row = anException.line;
-    col = anException.column;
-    message = anException.message;
-    lines = smalltalk.send(aString, "_lines", []);
-    badLine = smalltalk.send(lines, "_at_", [row]);
-    badLine = smalltalk.send(smalltalk.send(smalltalk.send(badLine, "_copyFrom_to_", [1, smalltalk.send(col, "__minus", [1])]), "__comma", [" ===>"]), "__comma", [smalltalk.send(badLine, "_copyFrom_to_", [col, smalltalk.send(badLine, "_size", [])])]);
-    smalltalk.send(lines, "_at_put_", [row, badLine]);
-    code = smalltalk.send(smalltalk.String || String, "_streamContents_", [function (s) {return smalltalk.send(lines, "_withIndexDo_", [function (l, i) {return smalltalk.send(s, "_nextPutAll_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(i, "_asString", []), "__comma", [": "]), "__comma", [l]), "__comma", [smalltalk.send(smalltalk.String || String, "_lf", [])])]);}]);}]);
-    $1 = smalltalk.send(smalltalk.send(smalltalk.ParseError || ParseError, "_new", []), "_messageText_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("Parse error on line ", "__comma", [row]), "__comma", [" column "]), "__comma", [col]), "__comma", [" : "]), "__comma", [message]), "__comma", [" Below is code with line numbers and ===> marker inserted:"]), "__comma", [smalltalk.send(smalltalk.String || String, "_lf", [])]), "__comma", [code])]);
-    return $1;
-},
+category: 'error handling',
+fn: function (anException,aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(_st((smalltalk.ParseError || ParseError))._new())._messageText_(_st(_st(_st(_st(_st("Parse error on line ").__comma(_st(anException)._basicAt_("line"))).__comma(" column ")).__comma(_st(anException)._basicAt_("column"))).__comma(" : Unexpected character ")).__comma(_st(anException)._basicAt_("found")));
+return $1;
+}, self, "parseError:parsing:", [anException,aString], smalltalk.Smalltalk)},
 args: ["anException", "aString"],
-source: "parseError: anException parsing: aString\x0a\x09| row col message lines badLine code |\x0a\x09<row = anException.line;\x0a\x09col = anException.column;\x0a\x09message = anException.message;>.\x0a\x09lines := aString lines.\x0a\x09badLine := lines at: row.\x0a\x09badLine := (badLine copyFrom: 1 to: col - 1), ' ===>', (badLine copyFrom:  col to: badLine size).\x0a\x09lines at: row put: badLine.\x0a\x09code := String streamContents: [:s |\x0a                  lines withIndexDo: [:l :i |\x0a                     s nextPutAll: i asString, ': ', l, String lf]].\x0a\x09^ ParseError new messageText: ('Parse error on line ' , row , ' column ' , col , ' : ' , message , ' Below is code with line numbers and ===> marker inserted:' , String lf, code)",
-messageSends: ["lines", "at:", ",", "copyFrom:to:", "size", "-", "at:put:", "streamContents:", "withIndexDo:", "nextPutAll:", "lf", "asString", "messageText:", "new"],
-referencedClasses: ["String", "ParseError"]
+source: "parseError: anException parsing: aString\x0a\x09^ ParseError new messageText: 'Parse error on line ', (anException basicAt: 'line') ,' column ' , (anException basicAt: 'column') ,' : Unexpected character ', (anException basicAt: 'found')",
+messageSends: ["messageText:", ",", "basicAt:", "new"],
+referencedClasses: ["ParseError"]
 }),
 smalltalk.Smalltalk);
 
@@ -4549,25 +4496,6 @@ referencedClasses: []
 }),
 smalltalk.Smalltalk);
 
-smalltalk.addMethod(
-"_send_to_arguments_",
-smalltalk.method({
-selector: "send:to:arguments:",
-category: 'accessing',
-fn: function (aSelector, anObject, aCollection) {
-    var self = this;
-    var selector;
-    selector = smalltalk.send(smalltalk.send(aSelector, "_asString", []), "_asSelector", []);
-    return self.send(anObject, selector, aCollection);
-    return self;
-},
-args: ["aSelector", "anObject", "aCollection"],
-source: "send: aSelector to: anObject arguments: aCollection\x0a\x09| selector |\x0a\x09selector := aSelector asString asSelector.\x0a\x09<return self.send(anObject, selector, aCollection)>",
-messageSends: ["asSelector", "asString"],
-referencedClasses: []
-}),
-smalltalk.Smalltalk);
-
 
 smalltalk.Smalltalk.klass.iVarNames = ['current'];
 smalltalk.addMethod(

+ 181 - 6
js/Kernel-Tests.deploy.js

@@ -1596,7 +1596,7 @@ smalltalk.method({
 selector: "jsObject",
 fn: function (){
 var self=this;
-return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: ''};
+return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null};
 ;
 return self}
 }),
@@ -1665,6 +1665,22 @@ return self}
 }),
 smalltalk.JSObjectProxyTest);
 
+smalltalk.addMethod(
+"_testPropertyThatReturnsUndefined",
+smalltalk.method({
+selector: "testPropertyThatReturnsUndefined",
+fn: function (){
+var self=this;
+var object;
+object=smalltalk.send(self,"_jsObject",[]);
+smalltalk.send(self,"_shouldnt_raise_",[(function(){
+return smalltalk.send(object,"_e",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_assert_",[smalltalk.send(smalltalk.send(object,"_e",[]),"_isNil",[])]);
+return self}
+}),
+smalltalk.JSObjectProxyTest);
+
 smalltalk.addMethod(
 "_testYourself",
 smalltalk.method({
@@ -1764,6 +1780,23 @@ return self}
 }),
 smalltalk.NumberTest);
 
+smalltalk.addMethod(
+"_testHexNumbers",
+smalltalk.method({
+selector: "testHexNumbers",
+fn: function (){
+var self=this;
+smalltalk.send(self,"_assert_",[smalltalk.send((9),"__eq",[(9)])]);
+smalltalk.send(self,"_assert_",[smalltalk.send(smalltalk.send((10),"_truncated",[]),"__eq",[(10)])]);
+smalltalk.send(self,"_assert_",[smalltalk.send(smalltalk.send((11),"_truncated",[]),"__eq",[(11)])]);
+smalltalk.send(self,"_assert_",[smalltalk.send(smalltalk.send((12),"_truncated",[]),"__eq",[(12)])]);
+smalltalk.send(self,"_assert_",[smalltalk.send(smalltalk.send((13),"_truncated",[]),"__eq",[(13)])]);
+smalltalk.send(self,"_assert_",[smalltalk.send(smalltalk.send((14),"_truncated",[]),"__eq",[(14)])]);
+smalltalk.send(self,"_assert_",[smalltalk.send(smalltalk.send((15),"_truncated",[]),"__eq",[(15)])]);
+return self}
+}),
+smalltalk.NumberTest);
+
 smalltalk.addMethod(
 "_testIdentity",
 smalltalk.method({
@@ -1781,6 +1814,139 @@ return self}
 }),
 smalltalk.NumberTest);
 
+smalltalk.addMethod(
+"_testInvalidHexNumbers",
+smalltalk.method({
+selector: "testInvalidHexNumbers",
+fn: function (){
+var self=this;
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rG",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rg",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rH",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rh",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rI",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_ri",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rJ",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rj",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rK",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rk",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rL",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rl",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rM",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rm",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rN",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rn",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rO",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_ro",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rP",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rp",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rQ",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rq",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rR",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rr",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rS",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rs",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rT",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rt",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rU",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_ru",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rV",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rv",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rW",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rw",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rX",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rx",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rY",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_ry",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rZ",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((16),"_rz",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+smalltalk.send(self,"_should_raise_",[(function(){
+return smalltalk.send((11259375),"_Z",[]);
+}),(smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
+return self}
+}),
+smalltalk.NumberTest);
+
 smalltalk.addMethod(
 "_testMinMax",
 smalltalk.method({
@@ -1952,6 +2118,18 @@ smalltalk.ObjectMock);
 
 
 smalltalk.addClass('ObjectTest', smalltalk.TestCase, [], 'Kernel-Tests');
+smalltalk.addMethod(
+"_notDefined",
+smalltalk.method({
+selector: "notDefined",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
return undefined;;
+;
+return self}, self, "notDefined", [], smalltalk.ObjectTest)}
+}),
+smalltalk.ObjectTest);
+
 smalltalk.addMethod(
 "_testBasicAccess",
 smalltalk.method({
@@ -2105,11 +2283,8 @@ smalltalk.method({
 selector: "testNilUndefined",
 fn: function (){
 var self=this;
-var notDefined;
-notDefined = undefined;
-;
-smalltalk.send(self,"_assert_",[smalltalk.send(nil,"__eq",[notDefined])]);
-return self}
+return smalltalk.withContext(function($ctx1) { 
_st(self)._assert_(_st(nil).__eq(_st(self)._notDefined()));
+return self}, self, "testNilUndefined", [], smalltalk.ObjectTest)}
 }),
 smalltalk.ObjectTest);
 

Разница между файлами не показана из-за своего большого размера
+ 177 - 2
js/Kernel-Tests.js


+ 6 - 0
st/Canvas.st

@@ -882,3 +882,9 @@ asJQuery
     <return jQuery(String(self))>
 ! !
 
+!JSObjectProxy methodsFor: '*Canvas'!
+
+asJQuery
+    <return jQuery(self['@jsObject'])>
+! !
+

+ 51 - 95
st/Kernel-Objects.st

@@ -68,15 +68,11 @@ identityHash
 !
 
 instVarAt: aSymbol
-	| varname |
-	varname := aSymbol asString.
-	<return self['@'+varname]>
+	<return self['@'+aSymbol._asString()]>
 !
 
 instVarAt: aSymbol put: anObject
-	| varname |
-	varname := aSymbol asString.
-	<self['@' + varname] = anObject>
+	<self['@' + aSymbol._asString()] = anObject>
 !
 
 size
@@ -229,9 +225,7 @@ perform: aSymbol
 !
 
 perform: aSymbol withArguments: aCollection
-	| selector |
-	selector := aSymbol asSelector.
-	<return smalltalk.send(self, selector, aCollection)>
+	<return smalltalk.send(self, aSymbol._asSelector(), aCollection)>
 ! !
 
 !Object methodsFor: 'printing'!
@@ -741,15 +735,11 @@ __Note:__ For keyword-based messages, only the first keyword is kept: `window fo
 !JSObjectProxy methodsFor: 'accessing'!
 
 at: aSymbol
-	| attr |
-	attr := aSymbol asString.
-	<return self['@jsObject'][attr]>
+	<return self['@jsObject'][aSymbol._asString()]>
 !
 
 at: aSymbol put: anObject
-	| attr |
-	attr := aSymbol asString.
-	<self['@jsObject'][attr] = anObject>
+	<self['@jsObject'][aSymbol._asString()] = anObject>
 !
 
 jsObject
@@ -762,13 +752,21 @@ jsObject: aJSObject
 
 !JSObjectProxy methodsFor: 'proxy'!
 
+addObjectVariablesTo: aDictionary
+	<for(var i in self['@jsObject']) {
+		aDictionary._at_put_(i, self['@jsObject'][i]);
+	}>.
+!
+
 doesNotUnderstand: aMessage
-	| obj selector jsSelector arguments |
-	obj := self jsObject.
-	selector := aMessage selector.
-	jsSelector := selector asJavaScriptSelector.
-	arguments := aMessage arguments.
-	<if(obj[jsSelector] !!= undefined) {return smalltalk.send(obj, jsSelector, arguments)}>.
+	<
+    	var jsSelector = aMessage._selector()._asJavaScriptSelector();
+        var object = self._jsObject();
+    	if(jsSelector in object) {
+        	return smalltalk.send(object, jsSelector, aMessage._arguments());
+        }
+    >.
+    
 	super doesNotUnderstand: aMessage
 !
 
@@ -777,9 +775,7 @@ inspectOn: anInspector
 	variables := Dictionary new.
 	variables at: '#self' put: self jsObject.
 	anInspector setLabel: self printString.
-	<for(var i in self['@jsObject']) {
-		variables._at_put_(i, self['@jsObject'][i]);
-	}>.
+	self addObjectVariablesTo: variables.
 	anInspector setVariables: variables
 !
 
@@ -962,13 +958,13 @@ to: stop by: step
 !
 
 truncated
-|result|
-
-    self >= 0 
-        ifTrue: [<result = Math.floor(self);>]
-        ifFalse: [<result = (Math.floor(self * (-1)) * (-1));>].
-
-    ^ result
+	<
+    	if(self >>= 0) {
+        	return Math.floor(self);
+        } else {
+        	return Math.floor(self * (-1)) * (-1);
+        };
+    >
 !
 
 | aNumber
@@ -1156,17 +1152,6 @@ organization
 
 properties
 	^Smalltalk current readJSObject: (self basicAt: 'properties')
-!
-
-properties: aDict
-	"We store it as a javascript object."
-	
-	| object |
-	<object = {};>.
-	aDict keysAndValuesDo: [:key :value |
-		<object[key] = value>.
-	].
-	<return self.properties = object>
 ! !
 
 !Package methodsFor: 'classes'!
@@ -1485,21 +1470,6 @@ parse: aString
 	^result
 !
 
-parseError: anException parsing: aString
-	| row col message lines badLine code |
-	<row = anException.line;
-	col = anException.column;
-	message = anException.message;>.
-	lines := aString lines.
-	badLine := lines at: row.
-	badLine := (badLine copyFrom: 1 to: col - 1), ' ===>', (badLine copyFrom:  col to: badLine size).
-	lines at: row put: badLine.
-	code := String streamContents: [:s |
-                  lines withIndexDo: [:l :i |
-                     s nextPutAll: i asString, ': ', l, String lf]].
-	^ ParseError new messageText: ('Parse error on line ' , row , ' column ' , col , ' : ' , message , ' Below is code with line numbers and ===> marker inserted:' , String lf, code)
-!
-
 readJSObject: anObject
 	<return self.readJSObject(anObject)>
 !
@@ -1507,12 +1477,6 @@ readJSObject: anObject
 reservedWords
 	"JavaScript reserved words"
 	<return self.reservedWords>
-!
-
-send: aSelector to: anObject arguments: aCollection
-	| selector |
-	selector := aSelector asString asSelector.
-	<return self.send(anObject, selector, aCollection)>
 ! !
 
 !Smalltalk methodsFor: 'classes'!
@@ -1521,6 +1485,12 @@ classes
 	<return self.classes()>
 !
 
+deleteClass: aClass
+	"Deletes a class by deleting its binding only. Use #removeClass instead"
+    
+	<self.removeClass(aClass)>
+!
+
 removeClass: aClass
 	aClass isMetaclass ifTrue: [self error: aClass asString, ' is a Metaclass and cannot be removed!!'].
     
@@ -1538,8 +1508,26 @@ removeClass: aClass
             yourself)
 ! !
 
+!Smalltalk methodsFor: 'error handling'!
+
+parseError: anException parsing: aString
+	^ ParseError new messageText: 'Parse error on line ', (anException basicAt: 'line') ,' column ' , (anException basicAt: 'column') ,' : Unexpected character ', (anException basicAt: 'found')
+! !
+
 !Smalltalk methodsFor: 'packages'!
 
+createPackage: packageName
+	"Create and bind a new package with given name and return it."
+       <return smalltalk.addPackage(packageName)>
+!
+
+deletePackage: packageName
+	"Deletes a package by deleting its binding, but does not check if it contains classes etc.
+	To remove a package, use #removePackage instead."
+
+       <delete smalltalk.packages[packageName]>
+!
+
 packageAt: packageName
        <return self.packages[packageName]>
 !
@@ -1579,38 +1567,6 @@ renamePackage: packageName to: newName
 	self deletePackage: packageName.
 ! !
 
-!Smalltalk methodsFor: 'private'!
-
-createPackage: packageName
-	"Create and bind a new package with given name and return it."
-
-      <return smalltalk.addPackage(packageName, nil)>
-!
-
-createPackage: packageName properties: aDict
-	"Create and bind a new package with given name and return it."
-
-	| object |
-	<object = {};>.
-	aDict keysAndValuesDo: [:key :value |
-		<object[key] = value>.
-	].
-       <return smalltalk.addPackage(packageName, object)>
-!
-
-deleteClass: aClass
-	"Deletes a class by deleting its binding only. Use #removeClass instead"
-    
-	<self.removeClass(aClass)>
-!
-
-deletePackage: packageName
-	"Deletes a package by deleting its binding, but does not check if it contains classes etc.
-	To remove a package, use #removePackage instead."
-
-       <delete smalltalk.packages[packageName]>
-! !
-
 Smalltalk class instanceVariableNames: 'current'!
 
 !Smalltalk class methodsFor: 'accessing'!

+ 73 - 7
st/Kernel-Tests.st

@@ -157,7 +157,9 @@ testLogicKeywords
 !
 
 testNonBooleanError
-    self should: ['' ifTrue: [] ifFalse: []] raise: NonBooleanReceiver
+	|b|
+    b := < '' >.
+    self should: [nonBoolean ifTrue: [] ifFalse: []] raise: NonBooleanReceiver
 ! !
 
 TestCase subclass: #ClassBuilderTest
@@ -824,7 +826,7 @@ TestCase subclass: #JSObjectProxyTest
 !JSObjectProxyTest methodsFor: 'accessing'!
 
 jsObject
-	<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: ''}>
+	<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null}>
 ! !
 
 !JSObjectProxyTest methodsFor: 'tests'!
@@ -858,6 +860,14 @@ testPropertyThatReturnsEmptyString
 	self assert: 'hello' equals: object d
 !
 
+testPropertyThatReturnsUndefined
+	| object |
+
+	object := self jsObject.
+	self shouldnt: [ object e ]  raise: MessageNotUnderstood.
+    self assert: object e isNil
+!
+
 testYourself
 	| object |
 	object := self jsObject
@@ -929,6 +939,17 @@ testEquality
 	self deny: 0 = ''
 !
 
+testHexNumbers
+
+	self assert: 16r9 = 9.
+	self assert: 16rA truncated = 10.
+	self assert: 16rB truncated = 11.
+	self assert: 16rC truncated = 12.
+	self assert: 16rD truncated = 13.
+	self assert: 16rE truncated = 14.
+	self assert: 16rF truncated = 15
+!
+
 testIdentity
 	self assert: 1 == 1.
 	self assert: 0 == 0.
@@ -941,6 +962,51 @@ testIdentity
 	self deny: 1 == 2
 !
 
+testInvalidHexNumbers
+
+	self should: [16rG] raise: MessageNotUnderstood.
+   	self should: [16rg] raise: MessageNotUnderstood.
+	self should: [16rH] raise: MessageNotUnderstood.
+   	self should: [16rh] raise: MessageNotUnderstood.
+	self should: [16rI] raise: MessageNotUnderstood.
+   	self should: [16ri] raise: MessageNotUnderstood.
+	self should: [16rJ] raise: MessageNotUnderstood.
+   	self should: [16rj] raise: MessageNotUnderstood.
+	self should: [16rK] raise: MessageNotUnderstood.
+   	self should: [16rk] raise: MessageNotUnderstood.
+	self should: [16rL] raise: MessageNotUnderstood.
+   	self should: [16rl] raise: MessageNotUnderstood.
+	self should: [16rM] raise: MessageNotUnderstood.
+   	self should: [16rm] raise: MessageNotUnderstood.
+	self should: [16rN] raise: MessageNotUnderstood.
+   	self should: [16rn] raise: MessageNotUnderstood.
+	self should: [16rO] raise: MessageNotUnderstood.
+   	self should: [16ro] raise: MessageNotUnderstood.
+	self should: [16rP] raise: MessageNotUnderstood.
+   	self should: [16rp] raise: MessageNotUnderstood.
+	self should: [16rQ] raise: MessageNotUnderstood.
+   	self should: [16rq] raise: MessageNotUnderstood.
+	self should: [16rR] raise: MessageNotUnderstood.
+   	self should: [16rr] raise: MessageNotUnderstood.
+	self should: [16rS] raise: MessageNotUnderstood.
+   	self should: [16rs] raise: MessageNotUnderstood.
+	self should: [16rT] raise: MessageNotUnderstood.
+   	self should: [16rt] raise: MessageNotUnderstood.
+	self should: [16rU] raise: MessageNotUnderstood.
+   	self should: [16ru] raise: MessageNotUnderstood.
+	self should: [16rV] raise: MessageNotUnderstood.
+   	self should: [16rv] raise: MessageNotUnderstood.
+	self should: [16rW] raise: MessageNotUnderstood.
+   	self should: [16rw] raise: MessageNotUnderstood.
+	self should: [16rX] raise: MessageNotUnderstood.
+   	self should: [16rx] raise: MessageNotUnderstood.
+	self should: [16rY] raise: MessageNotUnderstood.
+   	self should: [16ry] raise: MessageNotUnderstood.
+	self should: [16rZ] raise: MessageNotUnderstood.
+   	self should: [16rz] raise: MessageNotUnderstood.
+    self should: [16rABcdEfZ] raise: MessageNotUnderstood.
+!
+
 testMinMax
 	
 	self assert: (2 max: 5) equals: 5.
@@ -1034,6 +1100,10 @@ TestCase subclass: #ObjectTest
 
 !ObjectTest methodsFor: 'tests'!
 
+notDefined
+	<return undefined;>
+!
+
 testBasicAccess
 	| o |
 	o := Object new.
@@ -1100,11 +1170,7 @@ testInstVars
 testNilUndefined
 	"nil in Smalltalk is the undefined object in JS"
 
-	| notDefined |
-    
-    notDefined := window at: '__this_is_undefined'.
-
-	self assert: nil = notDefined
+	self assert: nil = self notDefined
 !
 
 testYourself

Некоторые файлы не были показаны из-за большого количества измененных файлов