ソースを参照

Added support for thisContext in the new compiler

Nicolas Petton 11 年 前
コミット
c3a37a2b20

+ 6 - 0
js/Compiler-IR.deploy.js

@@ -1935,7 +1935,13 @@ smalltalk.method({
 selector: "visitIRVariable:",
 fn: function (anIRVariable){
 var self=this;
+var $1;
+$1=smalltalk.send(smalltalk.send(anIRVariable,"_name",[]),"__eq",["thisContext"]);
+if(smalltalk.assert($1)){
+smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",["smalltalk.getThisContext()"]);
+} else {
 smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",[smalltalk.send(smalltalk.send(anIRVariable,"_variable",[]),"_alias",[])]);
+};
 return self}
 }),
 smalltalk.IRJSTranslator);

+ 8 - 2
js/Compiler-IR.js

@@ -2631,11 +2631,17 @@ selector: "visitIRVariable:",
 category: 'visiting',
 fn: function (anIRVariable){
 var self=this;
+var $1;
+$1=smalltalk.send(smalltalk.send(anIRVariable,"_name",[]),"__eq",["thisContext"]);
+if(smalltalk.assert($1)){
+smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",["smalltalk.getThisContext()"]);
+} else {
 smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",[smalltalk.send(smalltalk.send(anIRVariable,"_variable",[]),"_alias",[])]);
+};
 return self},
 args: ["anIRVariable"],
-source: "visitIRVariable: anIRVariable\x0a\x09self stream nextPutAll: anIRVariable variable alias",
-messageSends: ["nextPutAll:", "alias", "variable", "stream"],
+source: "visitIRVariable: anIRVariable\x0a\x09anIRVariable name = 'thisContext'\x0a    \x09ifTrue: [ self stream nextPutAll: 'smalltalk.getThisContext()' ]\x0a      \x09ifFalse: [ self stream nextPutAll: anIRVariable variable alias ]",
+messageSends: ["ifTrue:ifFalse:", "nextPutAll:", "stream", "alias", "variable", "=", "name"],
 referencedClasses: []
 }),
 smalltalk.IRJSTranslator);

+ 0 - 11
js/Compiler-Semantic.deploy.js

@@ -962,17 +962,6 @@ fn: function () {
 }),
 smalltalk.SemanticAnalyzer);
 
-smalltalk.addMethod(
-"_pseudoVariables",
-smalltalk.method({
-selector: "pseudoVariables",
-fn: function () {
-    var self = this;
-    return ["self", "super", "true", "false", "nil", "thisContext"];
-}
-}),
-smalltalk.SemanticAnalyzer);
-
 smalltalk.addMethod(
 "_pushScope_",
 smalltalk.method({

+ 0 - 16
js/Compiler-Semantic.js

@@ -1313,22 +1313,6 @@ referencedClasses: []
 }),
 smalltalk.SemanticAnalyzer);
 
-smalltalk.addMethod(
-"_pseudoVariables",
-smalltalk.method({
-selector: "pseudoVariables",
-category: 'accessing',
-fn: function () {
-    var self = this;
-    return ["self", "super", "true", "false", "nil", "thisContext"];
-},
-args: [],
-source: "pseudoVariables\x0a\x09^#('self' 'super' 'true' 'false' 'nil' 'thisContext')",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.SemanticAnalyzer);
-
 smalltalk.addMethod(
 "_pushScope_",
 smalltalk.method({

+ 3 - 3
js/Kernel-Objects.deploy.js

@@ -2963,9 +2963,9 @@ smalltalk.addMethod(
 "_pseudoVariableNames",
 smalltalk.method({
 selector: "pseudoVariableNames",
-fn: function () {
-    var self = this;
-    return ["self", "super", "nil", "true", "false"];
+fn: function (){
+var self=this;
+return ["self", "super", "nil", "true", "false", "thisContext"];
 }
 }),
 smalltalk.Smalltalk);

+ 4 - 4
js/Kernel-Objects.js

@@ -4083,12 +4083,12 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "pseudoVariableNames",
 category: 'packages',
-fn: function () {
-    var self = this;
-    return ["self", "super", "nil", "true", "false"];
+fn: function (){
+var self=this;
+return ["self", "super", "nil", "true", "false", "thisContext"];
 },
 args: [],
-source: "pseudoVariableNames\x0a\x09^ #('self' 'super' 'nil' 'true' 'false')",
+source: "pseudoVariableNames\x0a\x09^ #('self' 'super' 'nil' 'true' 'false' 'thisContext')",
 messageSends: [],
 referencedClasses: []
 }),

+ 3 - 1
st/Compiler-IR.st

@@ -912,7 +912,9 @@ visitIRValue: anIRValue
 !
 
 visitIRVariable: anIRVariable
-	self stream nextPutAll: anIRVariable variable alias
+	anIRVariable name = 'thisContext'
+    	ifTrue: [ self stream nextPutAll: 'smalltalk.getThisContext()' ]
+      	ifFalse: [ self stream nextPutAll: anIRVariable variable alias ]
 !
 
 visitIRVerbatim: anIRVerbatim

+ 0 - 4
st/Compiler-Semantic.st

@@ -385,10 +385,6 @@ messageSends
 	^ messageSends ifNil: [ messageSends := Dictionary new ]
 !
 
-pseudoVariables
-	^#('self' 'super' 'true' 'false' 'nil' 'thisContext')
-!
-
 theClass
 	^ theClass
 !

+ 1 - 1
st/Kernel-Objects.st

@@ -1441,7 +1441,7 @@ packages
 !
 
 pseudoVariableNames
-	^ #('self' 'super' 'nil' 'true' 'false')
+	^ #('self' 'super' 'nil' 'true' 'false' 'thisContext')
 !
 
 removePackage: packageName