|
@@ -315,14 +315,19 @@ function Smalltalk(){
|
|
|
smalltalk.Error._signal_(receiver + ' is not a Jtalk object and "' + jsSelector + '" is undefined')
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+ /* Reuse old contexts stored in oldContexts */
|
|
|
+
|
|
|
+ st.oldContexts = [];
|
|
|
+
|
|
|
|
|
|
/* Handle thisContext pseudo variable */
|
|
|
|
|
|
pushContext = function(receiver, selector, temps) {
|
|
|
if(thisContext) {
|
|
|
- return thisContext = thisContext.newContext({receiver: receiver, selector: selector, temps: temps});
|
|
|
+ return thisContext = thisContext.newContext(receiver, selector, temps);
|
|
|
} else {
|
|
|
- return thisContext = new SmalltalkMethodContext({receiver: receiver, selector: selector, temps: temps});
|
|
|
+ return thisContext = new SmalltalkMethodContext(receiver, selector, temps);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -395,21 +400,29 @@ function Smalltalk(){
|
|
|
st.setDevelopmentMode();
|
|
|
}
|
|
|
|
|
|
-function SmalltalkMethodContext(spec) {
|
|
|
+function SmalltalkMethodContext(receiver, selector, temps, home) {
|
|
|
var that = this;
|
|
|
- spec = spec || {};
|
|
|
- that.homeContext = spec.homeContext;
|
|
|
- that.selector = spec.selector;
|
|
|
- that.receiver = spec.receiver;
|
|
|
- that.temps = spec.temps || {};
|
|
|
-
|
|
|
- that.newContext = function(spec) {
|
|
|
- spec = spec || {};
|
|
|
- return new SmalltalkMethodContext({homeContext: that, receiver: spec.receiver, selector: spec.selector, temps: spec.temps});
|
|
|
+ that.receiver = receiver;
|
|
|
+ that.selector = selector;
|
|
|
+ that.temps = temps || {};
|
|
|
+ that.homeContext = home;
|
|
|
+
|
|
|
+ that.newContext = function(receiver, selector, temps) {
|
|
|
+ var c = smalltalk.oldContexts.pop();
|
|
|
+ if(c) {
|
|
|
+ c.homeContext = that;
|
|
|
+ c.receiver = receiver;
|
|
|
+ c.selector = selector;
|
|
|
+ c.temps = temps || {};
|
|
|
+ } else {
|
|
|
+ c = new SmalltalkMethodContext(receiver, selector, temps, that);
|
|
|
+ }
|
|
|
+ return c;
|
|
|
}
|
|
|
|
|
|
that.removeYourself = function() {
|
|
|
thisContext = that.homeContext;
|
|
|
+ smalltalk.oldContexts.push(that);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -419,7 +432,6 @@ var nil = new SmalltalkNil();
|
|
|
var smalltalk = new Smalltalk();
|
|
|
var thisContext = undefined;
|
|
|
|
|
|
-
|
|
|
/* Utilities */
|
|
|
|
|
|
Array.prototype.remove = function(s){
|