Procházet zdrojové kódy

Fixed Compiler>>visitClassReferenceNode: to lazily allow references to JS objects starting with a capital letter

Nicolas Petton před 13 roky
rodič
revize
15d97be96a
3 změnil soubory, kde provedl 12 přidání a 12 odebrání
  1. 3 3
      js/Compiler.deploy.js
  2. 7 7
      js/Compiler.js
  3. 2 2
      st/Compiler.st

+ 3 - 3
js/Compiler.deploy.js

@@ -1088,8 +1088,8 @@ selector: 'visitClassReferenceNode:',
 fn: function (aNode){
 var self=this;
 var klass=nil;
-klass=smalltalk.send("smalltalk.", "__comma", [smalltalk.send(aNode, "_value", [])]);
-smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Smalltalk, "_current", []), "_at_", [smalltalk.send(aNode, "_value", [])]), "_isClass", []), "_ifTrue_", [(function(){return smalltalk.send(smalltalk.send(self['@referencedClasses'], "_includes_", [klass]), "_ifFalse_", [(function(){return smalltalk.send(self['@referencedClasses'], "_add_", [klass]);})]);})]);
+klass=smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(unescape("%28smalltalk."), "__comma", [smalltalk.send(aNode, "_value", [])]), "__comma", [unescape("%20%7C%7C%20")]), "__comma", [smalltalk.send(aNode, "_value", [])]), "__comma", [unescape("%29")]);
+(($receiver = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Smalltalk, "_current", []), "_at_", [smalltalk.send(aNode, "_value", [])]), "_isClass", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (($receiver = smalltalk.send(self['@referencedClasses'], "_includes_", [klass])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self['@referencedClasses'], "_add_", [klass]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self['@referencedClasses'], "_add_", [klass]);})]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (($receiver = smalltalk.send(self['@referencedClasses'], "_includes_", [klass])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self['@referencedClasses'], "_add_", [klass]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self['@referencedClasses'], "_add_", [klass]);})]);})]);
 smalltalk.send(self['@stream'], "_nextPutAll_", [klass]);
 return self;}
 }),
@@ -1397,7 +1397,7 @@ smalltalk.method({
 selector: 'doIt',
 fn: function (){
 var self=this;
-return smalltalk.send((function(){return (1) == (2);}), "_value", []);
+return smalltalk.send((function(){return smalltalk.send((function(){return smalltalk.send((smalltalk.Object || Object), "_new", []);}), "_compiledSource", []);}), "_value", []);
 return self;}
 }),
 smalltalk.DoIt);

+ 7 - 7
js/Compiler.js

@@ -1441,11 +1441,11 @@ category: 'visiting',
 fn: function (aNode){
 var self=this;
 var klass=nil;
-klass=smalltalk.send("smalltalk.", "__comma", [smalltalk.send(aNode, "_value", [])]);
-smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Smalltalk, "_current", []), "_at_", [smalltalk.send(aNode, "_value", [])]), "_isClass", []), "_ifTrue_", [(function(){return smalltalk.send(smalltalk.send(self['@referencedClasses'], "_includes_", [klass]), "_ifFalse_", [(function(){return smalltalk.send(self['@referencedClasses'], "_add_", [klass]);})]);})]);
+klass=smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(unescape("%28smalltalk."), "__comma", [smalltalk.send(aNode, "_value", [])]), "__comma", [unescape("%20%7C%7C%20")]), "__comma", [smalltalk.send(aNode, "_value", [])]), "__comma", [unescape("%29")]);
+(($receiver = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Smalltalk, "_current", []), "_at_", [smalltalk.send(aNode, "_value", [])]), "_isClass", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (($receiver = smalltalk.send(self['@referencedClasses'], "_includes_", [klass])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self['@referencedClasses'], "_add_", [klass]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self['@referencedClasses'], "_add_", [klass]);})]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (($receiver = smalltalk.send(self['@referencedClasses'], "_includes_", [klass])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self['@referencedClasses'], "_add_", [klass]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self['@referencedClasses'], "_add_", [klass]);})]);})]);
 smalltalk.send(self['@stream'], "_nextPutAll_", [klass]);
 return self;},
-source: unescape('visitClassReferenceNode%3A%20aNode%0A%09%7C%20klass%20%7C%0A%09klass%20%3A%3D%20%27smalltalk.%27%2C%20aNode%20value.%0A%09%28Smalltalk%20current%20at%3A%20aNode%20value%29%20isClass%20ifTrue%3A%20%5B%0A%09%09%28referencedClasses%20includes%3A%20klass%29%0A%09%09%09ifFalse%3A%20%5BreferencedClasses%20add%3A%20klass%5D%5D.%0A%09stream%20nextPutAll%3A%20klass'),
+source: unescape('visitClassReferenceNode%3A%20aNode%0A%09%7C%20klass%20%7C%0A%09klass%20%3A%3D%20%27%28smalltalk.%27%2C%20aNode%20value%2C%20%27%20%7C%7C%20%27%2C%20aNode%20value%2C%20%27%29%27.%0A%09%28Smalltalk%20current%20at%3A%20aNode%20value%29%20isClass%20ifTrue%3A%20%5B%0A%09%09%28referencedClasses%20includes%3A%20klass%29%0A%09%09%09ifFalse%3A%20%5BreferencedClasses%20add%3A%20klass%5D%5D.%0A%09stream%20nextPutAll%3A%20klass'),
 messageSends: [unescape("%2C"), "value", "ifTrue:", "isClass", "at:", "current", "ifFalse:", "includes:", "add:", "nextPutAll:"],
 referencedClasses: [smalltalk.Smalltalk]
 }),
@@ -1846,11 +1846,11 @@ selector: 'doIt',
 category: '',
 fn: function (){
 var self=this;
-return smalltalk.send((function(){return (1) == (2);}), "_value", []);
+return smalltalk.send((function(){return smalltalk.send((function(){return smalltalk.send((smalltalk.Object || Object), "_new", []);}), "_compiledSource", []);}), "_value", []);
 return self;},
-source: unescape('doIt%20%5E%5B1%3D2%5D%20value'),
-messageSends: ["value", unescape("%3D")],
-referencedClasses: []
+source: unescape('doIt%20%5E%5B%5BObject%20new%5D%20compiledSource%5D%20value'),
+messageSends: ["value", "compiledSource", "new"],
+referencedClasses: [smalltalk.Object]
 }),
 smalltalk.DoIt);
 

+ 2 - 2
st/Compiler.st

@@ -949,7 +949,7 @@ visitAssignmentNode: aNode
 
 visitClassReferenceNode: aNode
 	| klass |
-	klass := 'smalltalk.', aNode value.
+	klass := '(smalltalk.', aNode value, ' || ', aNode value, ')'.
 	(Smalltalk current at: aNode value) isClass ifTrue: [
 		(referencedClasses includes: klass)
 			ifFalse: [referencedClasses add: klass]].
@@ -1023,6 +1023,6 @@ Object subclass: #DoIt
 
 !DoIt methodsFor: ''!
 
-doIt ^[1=2] value
+doIt ^[[Object new] compiledSource] value
 ! !