Selaa lähdekoodia

Merge remote branch 'upstream/master'

Göran Krampe 12 vuotta sitten
vanhempi
commit
aec46c69cf

+ 5 - 5
examples/presentation/js/Presentation.deploy.js

@@ -61,7 +61,7 @@ selector: 'show',
 fn: function (){
 var self=this;
 smalltalk.send(smalltalk.send((typeof document == 'undefined' ? nil : document), "_location", []), "_hash_", [smalltalk.send(self, "_id", [])]);
-(($receiver = smalltalk.send(self, "_backgroundColor", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(smalltalk.send((typeof window == 'undefined' ? nil : window), "_jQuery_", [unescape("%23slides")]), "_animate_duration_", [smalltalk.send((smalltalk.Dictionary || Dictionary), "_with_", [smalltalk.send("backgroundColor", "__minus_gt", [smalltalk.send(self, "_backgroundColor", [])])]), (500)]);})() : nil;
+(($receiver = smalltalk.send(self, "_backgroundColor", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(smalltalk.send((typeof window == 'undefined' ? nil : window), "_jQuery_", [unescape("%23slides")]), "_css_color_", ["background", smalltalk.send(self, "_backgroundColor", [])]);})() : nil;
 smalltalk.send(smalltalk.send((typeof window == 'undefined' ? nil : window), "_jQuery_", [".slide"]), "_hide_options_duration_", [smalltalk.send(smalltalk.send(self, "_presentation", []), "_slideTransition", []), [], (300)]);
 smalltalk.send(smalltalk.send((typeof window == 'undefined' ? nil : window), "_jQuery_", [smalltalk.send(unescape("%23"), "__comma", [smalltalk.send(self, "_id", [])])]), "_show_options_duration_", [smalltalk.send(smalltalk.send(self, "_presentation", []), "_slideTransition", []), [], (300)]);
 return self;}
@@ -247,7 +247,7 @@ selector: 'setup',
 fn: function (){
 var self=this;
 smalltalk.send((smalltalk.Presentation || Presentation), "_setCurrent_", [self]);
-smalltalk.send((smalltalk.JQuery || JQuery), "_documentReady_", [(function(){smalltalk.send(smalltalk.send("body", "_asJQuery", []), "_append_", [self]);return (function($rec){smalltalk.send($rec, "_setKeybindings", []);smalltalk.send($rec, "_checkHashChange", []);return smalltalk.send($rec, "_checkHash", []);})(self);})]);
+smalltalk.send(smalltalk.send((typeof window == 'undefined' ? nil : window), "_jQuery_", [(typeof document == 'undefined' ? nil : document)]), "_ready_", [(function(){smalltalk.send(self, "_appendToJQuery_", [smalltalk.send("body", "_asJQuery", [])]);return (function($rec){smalltalk.send($rec, "_setKeybindings", []);smalltalk.send($rec, "_checkHashChange", []);return smalltalk.send($rec, "_checkHash", []);})(self);})]);
 return self;}
 }),
 smalltalk.Presentation);
@@ -293,8 +293,8 @@ smalltalk.method({
 selector: 'setKeybindings',
 fn: function (){
 var self=this;
-smalltalk.send(smalltalk.send((smalltalk.JQuery || JQuery), "_document", []), "_on_do_", ["keyup", (function(e){var node=nil;
-node=smalltalk.send(smalltalk.send(smalltalk.send(e, "_target", []), "_nodeName", []), "_asLowercase", []);return (($receiver = smalltalk.send(smalltalk.send(node, "__eq", ["textarea"]), "_or_", [(function(){return smalltalk.send(node, "__eq", ["input"]);})])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){(($receiver = smalltalk.send(smalltalk.send(e, "_keyCode", []), "__eq", [(39)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_nextSlide", []);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_nextSlide", []);})]);return (($receiver = smalltalk.send(smalltalk.send(e, "_keyCode", []), "__eq", [(37)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_previousSlide", []);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_previousSlide", []);})]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){(($receiver = smalltalk.send(smalltalk.send(e, "_keyCode", []), "__eq", [(39)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_nextSlide", []);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_nextSlide", []);})]);return (($receiver = smalltalk.send(smalltalk.send(e, "_keyCode", []), "__eq", [(37)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_previousSlide", []);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_previousSlide", []);})]);})]);})]);
+smalltalk.send(smalltalk.send((typeof window == 'undefined' ? nil : window), "_jQuery_", [(typeof document == 'undefined' ? nil : document)]), "_keyup_", [(function(e){var node=nil;
+node=smalltalk.send(smalltalk.send(smalltalk.send(e, "_target", []), "_nodeName", []), "_asLowercase", []);return ((($receiver = smalltalk.send(smalltalk.send(node, "__eq", ["textarea"]), "_or_", [(function(){return smalltalk.send(node, "__eq", ["input"]);})])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){((($receiver = smalltalk.send(smalltalk.send(e, "_keyCode", []), "__eq", [(39)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_nextSlide", []);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_nextSlide", []);})]));return ((($receiver = smalltalk.send(smalltalk.send(e, "_keyCode", []), "__eq", [(37)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_previousSlide", []);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_previousSlide", []);})]));})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){((($receiver = smalltalk.send(smalltalk.send(e, "_keyCode", []), "__eq", [(39)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_nextSlide", []);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_nextSlide", []);})]));return ((($receiver = smalltalk.send(smalltalk.send(e, "_keyCode", []), "__eq", [(37)])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_previousSlide", []);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_previousSlide", []);})]));})]));})]);
 return self;}
 }),
 smalltalk.Presentation);
@@ -305,7 +305,7 @@ smalltalk.method({
 selector: 'checkHashChange',
 fn: function (){
 var self=this;
-smalltalk.send(smalltalk.send((smalltalk.JQuery || JQuery), "_window", []), "_on_do_", ["hashchange", (function(){return smalltalk.send(self, "_checkHash", []);})]);
+smalltalk.send(smalltalk.send((typeof window == 'undefined' ? nil : window), "_jQuery_", [(typeof window == 'undefined' ? nil : window)]), "_bind_do_", ["hashchange", (function(){return smalltalk.send(self, "_checkHash", []);})]);
 return self;}
 }),
 smalltalk.Presentation);

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 174 - 174
examples/presentation/js/Presentation.js


+ 5 - 5
examples/presentation/st/Presentation.st

@@ -29,7 +29,7 @@ backgroundColor
 show
 	document location hash: self id.
 	self backgroundColor ifNotNil: [
-		(window jQuery: '#slides') animate: (Dictionary with: 'backgroundColor' -> self backgroundColor) duration: 500].
+		(window jQuery: '#slides') css: 'background' color: self backgroundColor].
 	(window jQuery: '.slide') hide: self presentation slideTransition options: #() duration: 300.
 	(window jQuery: '#', self id) show: self presentation slideTransition options: #() duration: 300.
 ! !
@@ -126,8 +126,8 @@ reload
 
 setup
 	Presentation setCurrent: self.
-	JQuery documentReady: [
-		'body' asJQuery append: self.
+	(window jQuery: document) ready: [
+		self appendToJQuery: 'body' asJQuery.
 		self 
 			setKeybindings;
 			checkHashChange;
@@ -159,7 +159,7 @@ previousSlide
 !
 
 setKeybindings
-	JQuery document on: 'keyup' do: [:e || node |
+	(window jQuery: document) keyup: [:e || node |
 		node := e target nodeName asLowercase.
 		(node = 'textarea' or: [node = 'input']) ifFalse: [
 			e keyCode = 39 ifTrue: [self nextSlide].
@@ -167,7 +167,7 @@ setKeybindings
 !
 
 checkHashChange
-	JQuery window on: 'hashchange' do: [self checkHash]
+	(window jQuery: window) bind: 'hashchange' do: [self checkHash]
 !
 
 checkHash

+ 3 - 2
index.html

@@ -48,8 +48,9 @@
 	    <p><b>Try a <button onClick="smalltalk.Browser._open()"> Class browser</button> right now!</b></p> 
 	  </div> 
 	  <div class="column">
-	    <h2>Don't know Smalltalk yet?</h2>
-	    <p>No problem! You can learn it online with <a href="http://amber-lang.net/learn.html">ProfStef</a></p>
+	    <h2>Getting started</h2>
+	    <p>The <a href="https://github.com/NicolasPetton/amber/wiki">Wiki on GitHub</a> includes a <a href="https://github.com/NicolasPetton/amber/wiki/Getting-started">Getting started</a> tutorial for OSX, Linux and Windows.</p>
+	    <p>If you're new to Smalltalk, You can learn it online with <a href="http://amber-lang.net/learn.html">ProfStef</a>.</p>
 	    <h2>Join the community</h2>
 	    <ul>
 	      <li><a href="http://amber-lang.net">Amber's website</a></li>

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 2 - 1
js/Compiler.deploy.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 9 - 8
js/Compiler.js


+ 47 - 1
js/Kernel.deploy.js

@@ -548,6 +548,17 @@ return self;}
 }),
 smalltalk.Object);
 
+smalltalk.addMethod(
+'_deprecatedAPI',
+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")])]);
+return self;}
+}),
+smalltalk.Object);
+
 
 smalltalk.addMethod(
 '_initialize',
@@ -743,6 +754,17 @@ return self;}
 }),
 smalltalk.Smalltalk);
 
+smalltalk.addMethod(
+'_reservedWords',
+smalltalk.method({
+selector: 'reservedWords',
+fn: function (){
+var self=this;
+return self.reservedWords;
+return self;}
+}),
+smalltalk.Smalltalk);
+
 
 smalltalk.Smalltalk.klass.iVarNames = ['current'];
 smalltalk.addMethod(
@@ -3960,6 +3982,17 @@ return self;
 }),
 smalltalk.String);
 
+smalltalk.addMethod(
+'_asJavaScriptSelector',
+smalltalk.method({
+selector: 'asJavaScriptSelector',
+fn: function (){
+var self=this;
+return String(self.replace(/^_/, '').replace(/_.*/, ''));
+return self;}
+}),
+smalltalk.String);
+
 
 smalltalk.addMethod(
 '_streamClass',
@@ -5609,6 +5642,17 @@ return self;}
 }),
 smalltalk.Point);
 
+smalltalk.addMethod(
+'__eq',
+smalltalk.method({
+selector: '=',
+fn: function (aPoint){
+var self=this;
+return smalltalk.send(smalltalk.send(smalltalk.send(aPoint, "_class", []), "__eq", [smalltalk.send(self, "_class", [])]), "_and_", [(function(){return smalltalk.send(smalltalk.send(smalltalk.send(aPoint, "_x", []), "__eq", [smalltalk.send(self, "_x", [])]), "_&", [smalltalk.send(smalltalk.send(aPoint, "_y", []), "__eq", [smalltalk.send(self, "_y", [])])]);})]);
+return self;}
+}),
+smalltalk.Point);
+
 
 smalltalk.addMethod(
 '_x_y_',
@@ -5903,11 +5947,13 @@ fn: function (aMessage){
 var self=this;
 var obj=nil;
 var selector=nil;
+var jsSelector=nil;
 var arguments=nil;
 obj=smalltalk.send(self, "_jsObject", []);
 selector=smalltalk.send(aMessage, "_selector", []);
+jsSelector=smalltalk.send(selector, "_asJavaScriptSelector", []);
 arguments=smalltalk.send(aMessage, "_arguments", []);
-if(obj[selector]) {return smalltalk.send(obj, selector, arguments)};
+if(obj[jsSelector]) {return smalltalk.send(obj, jsSelector, arguments)};
 smalltalk.send(self, "_doesNotUnderstand_", [aMessage], smalltalk.Object);
 return self;}
 }),

+ 69 - 3
js/Kernel.js

@@ -788,6 +788,22 @@ referencedClasses: []
 }),
 smalltalk.Object);
 
+smalltalk.addMethod(
+unescape('_deprecatedAPI'),
+smalltalk.method({
+selector: unescape('deprecatedAPI'),
+category: 'error handling',
+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")])]);
+return self;},
+args: [],
+source: unescape('deprecatedAPI%0A%09%22Just%20a%20simple%20way%20to%20deprecate%20methods.%0A%09%23deprecatedAPI%20is%20in%20the%20%27error%20handling%27%20protocol%20even%20if%20it%20doesn%27t%20throw%20an%20error%2C%0A%09but%20it%20could%20in%20the%20future.%22%0A%09console%20warn%3A%20thisContext%20home%20asString%2C%20%27%20is%20deprecated%21%27'),
+messageSends: ["warn:", unescape("%2C"), "asString", "home"],
+referencedClasses: []
+}),
+smalltalk.Object);
+
 
 smalltalk.addMethod(
 unescape('_initialize'),
@@ -1058,6 +1074,22 @@ referencedClasses: []
 }),
 smalltalk.Smalltalk);
 
+smalltalk.addMethod(
+unescape('_reservedWords'),
+smalltalk.method({
+selector: unescape('reservedWords'),
+category: 'accessing',
+fn: function (){
+var self=this;
+return self.reservedWords;
+return self;},
+args: [],
+source: unescape('reservedWords%0A%09%22JavaScript%20reserved%20words%22%0A%09%3Creturn%20self.reservedWords%3E'),
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.Smalltalk);
+
 
 smalltalk.Smalltalk.klass.iVarNames = ['current'];
 smalltalk.addMethod(
@@ -5652,6 +5684,22 @@ referencedClasses: []
 }),
 smalltalk.String);
 
+smalltalk.addMethod(
+unescape('_asJavaScriptSelector'),
+smalltalk.method({
+selector: unescape('asJavaScriptSelector'),
+category: 'converting',
+fn: function (){
+var self=this;
+return String(self.replace(/^_/, '').replace(/_.*/, ''));
+return self;},
+args: [],
+source: unescape('asJavaScriptSelector%0A%09%3Creturn%20String%28self.replace%28/%5E_/%2C%20%27%27%29.replace%28/_.*/%2C%20%27%27%29%29%3E'),
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.String);
+
 
 smalltalk.addMethod(
 unescape('_streamClass'),
@@ -7991,6 +8039,22 @@ referencedClasses: []
 }),
 smalltalk.Point);
 
+smalltalk.addMethod(
+unescape('__eq'),
+smalltalk.method({
+selector: unescape('%3D'),
+category: 'arithmetic',
+fn: function (aPoint){
+var self=this;
+return smalltalk.send(smalltalk.send(smalltalk.send(aPoint, "_class", []), "__eq", [smalltalk.send(self, "_class", [])]), "_and_", [(function(){return smalltalk.send(smalltalk.send(smalltalk.send(aPoint, "_x", []), "__eq", [smalltalk.send(self, "_x", [])]), "_&", [smalltalk.send(smalltalk.send(aPoint, "_y", []), "__eq", [smalltalk.send(self, "_y", [])])]);})]);
+return self;},
+args: ["aPoint"],
+source: unescape('%3D%20aPoint%0A%09%5EaPoint%20class%20%3D%20self%20class%20and%3A%20%5B%0A%09%09%28aPoint%20x%20%3D%20self%20x%29%20%26%20%28aPoint%20y%20%3D%20self%20y%29%5D'),
+messageSends: ["and:", unescape("%3D"), "class", unescape("%26"), "x", "y"],
+referencedClasses: []
+}),
+smalltalk.Point);
+
 
 smalltalk.addMethod(
 unescape('_x_y_'),
@@ -8406,16 +8470,18 @@ fn: function (aMessage){
 var self=this;
 var obj=nil;
 var selector=nil;
+var jsSelector=nil;
 var arguments=nil;
 obj=smalltalk.send(self, "_jsObject", []);
 selector=smalltalk.send(aMessage, "_selector", []);
+jsSelector=smalltalk.send(selector, "_asJavaScriptSelector", []);
 arguments=smalltalk.send(aMessage, "_arguments", []);
-if(obj[selector]) {return smalltalk.send(obj, selector, arguments)};
+if(obj[jsSelector]) {return smalltalk.send(obj, jsSelector, arguments)};
 smalltalk.send(self, "_doesNotUnderstand_", [aMessage], smalltalk.Object);
 return self;},
 args: ["aMessage"],
-source: unescape('doesNotUnderstand%3A%20aMessage%0A%09%7C%20obj%20selector%20arguments%20%7C%0A%09obj%20%3A%3D%20self%20jsObject.%0A%09selector%20%3A%3D%20aMessage%20selector.%0A%09arguments%20%3A%3D%20aMessage%20arguments.%0A%09%3Cif%28obj%5Bselector%5D%29%20%7Breturn%20smalltalk.send%28obj%2C%20selector%2C%20arguments%29%7D%3E.%0A%09super%20doesNotUnderstand%3A%20aMessage'),
-messageSends: ["jsObject", "selector", "arguments", "doesNotUnderstand:"],
+source: unescape('doesNotUnderstand%3A%20aMessage%0A%09%7C%20obj%20selector%20jsSelector%20arguments%20%7C%0A%09obj%20%3A%3D%20self%20jsObject.%0A%09selector%20%3A%3D%20aMessage%20selector.%0A%09jsSelector%20%3A%3D%20selector%20asJavaScriptSelector.%0A%09arguments%20%3A%3D%20aMessage%20arguments.%0A%09%3Cif%28obj%5BjsSelector%5D%29%20%7Breturn%20smalltalk.send%28obj%2C%20jsSelector%2C%20arguments%29%7D%3E.%0A%09super%20doesNotUnderstand%3A%20aMessage'),
+messageSends: ["jsObject", "selector", "asJavaScriptSelector", "arguments", "doesNotUnderstand:"],
 referencedClasses: []
 }),
 smalltalk.JSObjectProxy);

+ 30 - 5
js/boot.js

@@ -33,6 +33,19 @@
    |
    ==================================================================== */
 
+/* Make that console is defined */
+
+if (typeof console === "undefined") {
+    this.console = {
+	log: function() {},
+	warn: function() {},
+	info: function() {},
+	debug: function() {},
+	error: function() {},
+    };
+}
+
+
 /* Smalltalk constructors definition */
 
 function SmalltalkObject(){};
@@ -48,13 +61,27 @@ function SmalltalkNil(){};
 function Smalltalk(){
 
     var st = this;
-    this.thisContext = undefined;
 
+    /* This is the current call context object. While it is publicly available,
+       Use smalltalk.getThisContext() instead which will answer a safe copy of 
+       the current context */
+
+    st.thisContext = undefined;
+
+    /* List of all reserved words in JavaScript. They may not be used as variables
+       in Smalltalk. */
+
+    st.reservedWords = ['break', 'case', 'catch', 'class', 'continue', 'debugger', 
+			'default', 'delete', 'do', 'else', 'finally', 'for', 'function', 
+			'if', 'in', 'instanceof', 'new', 'private', 'protected', 
+			'public', 'return', 'static', 'switch', 'this', 'throw',
+			'try', 'typeof', 'var', 'void', 'while', 'with', 'yield'];
     
     /* We hold all Packages in a separate Object */
+
     st.packages = {};
 
-    /* Smalltalk Package object. To add a Package, use smalltalk.addPackage() */
+    /* Smalltalk package creation. To add a Package, use smalltalk.addPackage() */
 
     function pkg(spec) {
 	var that      = new SmalltalkPackage();
@@ -345,9 +372,7 @@ function Smalltalk(){
 	   Example:
 	   "self do: aBlock with: anObject" -> "self.do(aBlock, anObject)" */
 
-	var jsSelector = selector
-	    .replace(/^_/, '')
-	    .replace(/_.*/g, '');
+	var jsSelector = selector._asJavaScriptSelector();
 	var jsProperty = receiver[jsSelector];
 	if(typeof jsProperty === "function") {
 	    return jsProperty.apply(receiver, args);

+ 20 - 10
st/Compiler.st

@@ -779,6 +779,12 @@ source: aString
 
 argVariables
 	^argVariables copy
+!
+
+safeVariableNameFor: aString
+	^(Smalltalk current reservedWords includes: aString)
+		ifTrue: [aString, '_']
+		ifFalse: [aString]
 ! !
 
 !Compiler methodsFor: 'compiling'!
@@ -1184,9 +1190,10 @@ visitBlockNode: aNode
 !
 
 visitSequenceNode: aNode
-	aNode temps do: [:each |
-	    tempVariables add: each.
-	    stream nextPutAll: 'var ', each, '=nil;'; lf].
+	aNode temps do: [:each || temp |
+            temp := self safeVariableNameFor: each.
+	    tempVariables add: temp.
+	    stream nextPutAll: 'var ', temp, '=nil;'; lf].
 	aNode nodes do: [:each |
 	    self visit: each.
 	    stream nextPutAll: ';']
@@ -1200,9 +1207,10 @@ visitBlockSequenceNode: aNode
 	    ifTrue: [
 		stream nextPutAll: 'return nil;']
 	    ifFalse: [
-		aNode temps do: [:each |
-		    tempVariables add: each.
-		    stream nextPutAll: 'var ', each, '=nil;'; lf].
+		aNode temps do: [:each | | temp |
+                    temp := self safeVariableNameFor: each.
+		    tempVariables add: temp.
+		    stream nextPutAll: 'var ', temp, '=nil;'; lf].
 		index := 0.
 		aNode nodes do: [:each |
 		    index := index + 1.
@@ -1288,19 +1296,21 @@ visitClassReferenceNode: aNode
 !
 
 visitVariableNode: aNode
+	| varName |
 	(self currentClass allInstanceVariableNames includes: aNode value) 
 		ifTrue: [stream nextPutAll: 'self[''@', aNode value, ''']']
 		ifFalse: [
-			(self knownVariables includes: aNode value) 
+                  	varName := self safeVariableNameFor: aNode value.
+			(self knownVariables includes: varName) 
                   		ifFalse: [
                                   	unknownVariables add: aNode value.
                                   	aNode assigned 
-                                  		ifTrue: [stream nextPutAll: aNode value]
-                                  		ifFalse: [stream nextPutAll: '(typeof ', aNode value, ' == ''undefined'' ? nil : ', aNode value, ')']]
+                                  		ifTrue: [stream nextPutAll: varName]
+                                  		ifFalse: [stream nextPutAll: '(typeof ', varName, ' == ''undefined'' ? nil : ', varName, ')']]
                   		ifTrue: [
                                   	aNode value = 'thisContext'
                                   		ifTrue: [stream nextPutAll: '(smalltalk.getThisContext())']
-                				ifFalse: [stream nextPutAll:aNode value]]]
+                				ifFalse: [stream nextPutAll: varName]]]
 !
 
 visitJSStatementNode: aNode

+ 24 - 2
st/Kernel.st

@@ -140,6 +140,13 @@ doesNotUnderstand: aMessage
 
 halt
 	self error: 'Halt encountered'
+!
+
+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!!'
 ! !
 
 !Object methodsFor: 'initialization'!
@@ -289,6 +296,11 @@ parseError: anException parsing: aString
                   lines withIndexDo: [:l :i |
                      s nextPutAll: i asString, ': ', l, String lf]].
 	^ Error new messageText: ('Parse error on line ' , row , ' column ' , col , ' : ' , message , ' Below is code with line numbers and ===> marker inserted:' , String lf, code)
+!
+
+reservedWords
+	"JavaScript reserved words"
+	<return self.reservedWords>
 ! !
 
 !Smalltalk methodsFor: 'classes'!
@@ -1778,6 +1790,10 @@ asUppercase
 
 reversed
 	<return self.split("").reverse().join("")>
+!
+
+asJavaScriptSelector
+	<return String(self.replace(/^_/, '').replace(/_.*/, ''))>
 ! !
 
 !String methodsFor: 'copying'!
@@ -2778,6 +2794,11 @@ x: aNumber
 
 / aPoint
 	^Point x: self x / aPoint asPoint x y: self y / aPoint asPoint y
+!
+
+= aPoint
+	^aPoint class = self class and: [
+		(aPoint x = self x) & (aPoint y = self y)]
 ! !
 
 !Point methodsFor: 'converting'!
@@ -2947,11 +2968,12 @@ inspectOn: anInspector
 !
 
 doesNotUnderstand: aMessage
-	| obj selector arguments |
+	| obj selector jsSelector arguments |
 	obj := self jsObject.
 	selector := aMessage selector.
+	jsSelector := selector asJavaScriptSelector.
 	arguments := aMessage arguments.
-	<if(obj[selector]) {return smalltalk.send(obj, selector, arguments)}>.
+	<if(obj[jsSelector]) {return smalltalk.send(obj, jsSelector, arguments)}>.
 	super doesNotUnderstand: aMessage
 ! !
 

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä