Added support for thisContext in the new compiler

This commit is contained in:
Nicolas Petton 2012-10-07 20:24:50 +02:00
parent 82334632f9
commit c3a37a2b20
9 changed files with 25 additions and 42 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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({

View File

@ -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({

View File

@ -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);

View File

@ -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: []
}),

View File

@ -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

View File

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

View File

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