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

Merge pull request #187 from herby/master

Different fixes.
Nicolas Petton 12 лет назад
Родитель
Сommit
783927fa01
6 измененных файлов с 495 добавлено и 495 удалено
  1. 21 21
      js/Compiler.deploy.js
  2. 30 30
      js/Compiler.js
  3. 221 219
      js/Kernel-Collections.deploy.js
  4. 210 209
      js/Kernel-Collections.js
  5. 11 15
      st/Compiler.st
  6. 2 1
      st/Kernel-Collections.st

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


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


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


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


+ 11 - 15
st/Compiler.st

@@ -113,7 +113,7 @@ exportDefinitionOf: aClass on: aStream
 		nextPutAll: 'smalltalk.';
 		nextPutAll: (self classNameFor: aClass);
 		nextPutAll: '.comment=';
-		nextPutAll: 'unescape(''', aClass comment escaped, ''')'].
+		nextPutAll: aClass comment asJavascript].
 	aStream lf
 !
 
@@ -131,13 +131,13 @@ exportMetaDefinitionOf: aClass on: aStream
 exportMethod: aMethod of: aClass on: aStream
 	aStream 
 		nextPutAll: 'smalltalk.addMethod(';lf;
-		nextPutAll: 'unescape(''', aMethod selector asSelector escaped, '''),';lf;
+		nextPutAll: aMethod selector asSelector asJavascript, ',';lf;
 		nextPutAll: 'smalltalk.method({';lf;
-		nextPutAll: 'selector: unescape(''', aMethod selector escaped, '''),';lf;
+		nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;
 		nextPutAll: 'category: ''', aMethod category, ''',';lf;
 		nextPutAll: 'fn: ', aMethod fn compiledSource, ',';lf;
 		nextPutAll: 'args: ', aMethod arguments asJavascript, ','; lf;
-		nextPutAll: 'source: unescape(''', aMethod source escaped, '''),';lf;
+		nextPutAll: 'source: ', aMethod source asJavascript, ',';lf;
 		nextPutAll: 'messageSends: ', aMethod messageSends asJavascript, ',';lf;
 		nextPutAll: 'referencedClasses: ', aMethod referencedClasses asJavascript.
 	aStream
@@ -314,9 +314,9 @@ exportDefinitionOf: aClass on: aStream
 exportMethod: aMethod of: aClass on: aStream
 	aStream 
 		nextPutAll: 'smalltalk.addMethod(';lf;
-		nextPutAll: 'unescape(''', aMethod selector asSelector escaped, '''),';lf;
+		nextPutAll: aMethod selector asSelector asJavascript, ',';lf;
 		nextPutAll: 'smalltalk.method({';lf;
-		nextPutAll: 'selector: unescape(''', aMethod selector escaped, '''),';lf;
+		nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;
 		nextPutAll: 'fn: ', aMethod fn compiledSource;lf;
 		nextPutAll: '}),';lf;
 		nextPutAll: 'smalltalk.', (self classNameFor: aClass);
@@ -732,7 +732,7 @@ visitBlockNode: aNode
 !
 
 visitBlockSequenceNode: aNode
-	self visitSequenceNode: aNode
+	self visitNode: aNode
 !
 
 visitCascadeNode: aNode
@@ -740,9 +740,7 @@ visitCascadeNode: aNode
 !
 
 visitClassReferenceNode: aNode
-	self 
-	    nextPutAll: 'smalltalk.';
-	    nextPutAll: aNode value
+	self visitNode: aNode
 !
 
 visitDynamicArrayNode: aNode
@@ -754,10 +752,7 @@ visitDynamicDictionaryNode: aNode
 !
 
 visitJSStatementNode: aNode
-	self 
-	    nextPutAll: 'function(){';
-	    nextPutAll: aNode source;
-	    nextPutAll: '})()'
+	self visitNode: aNode
 !
 
 visitMethodNode: aNode
@@ -784,6 +779,7 @@ visitValueNode: aNode
 !
 
 visitVariableNode: aNode
+	self visitNode: aNode
 ! !
 
 NodeVisitor subclass: #Compiler
@@ -1310,7 +1306,7 @@ visitMethodNode: aNode
 	stream 
 	    nextPutAll: 'smalltalk.method({'; lf;
 	    nextPutAll: 'selector: "', aNode selector, '",'; lf.
-	stream nextPutAll: 'source: unescape("', self source escaped, '"),';lf.
+	stream nextPutAll: 'source: ', self source asJavascript, ',';lf.
 	stream nextPutAll: 'fn: function('.
 	aNode arguments 
 	    do: [:each | 

+ 2 - 1
st/Kernel-Collections.st

@@ -319,6 +319,7 @@ at: aKey put: aValue
 
 keys
 	<
+		if ('function'===typeof Object.keys) return Object.keys(self);
 		var keys = [];
 		for(var i in self) {
 			if(self.hasOwnProperty(i)) {
@@ -975,7 +976,7 @@ asJavaScriptSelector
 asJavascript
 	<
 		if(self.search(/^[a-zA-Z0-9_:.$ ]*$/) == -1)
-			return "unescape(\"" + escape(self) + "\")";
+			return "\"" + self.replace(/[\x00-\x1f"\\\x7f-\x9f]/g, function(ch){var c=ch.charCodeAt(0);return "\\x"+("0"+c.toString(16)).slice(-2)}) + "\"";
 		else
 			return "\"" + self + "\"";
 	>

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