Browse Source

A way for block context to see parent context.

Via JS prototype inheritance.
Herbert Vojčík 11 years ago
parent
commit
9098952ddb
1 changed files with 7 additions and 5 deletions
  1. 7 5
      js/boot.js

+ 7 - 5
js/boot.js

@@ -727,10 +727,15 @@ function SmalltalkMethodContext(home, setup) {
 	this.homeContext = home;
     this.setup       = setup || function() {};
     this.pc          = 0;
-    this.locals      = {};
-    this.args        = [];
 }
 
+// Fallbacks
+SmalltalkMethodContext.prototype.args = [];
+SmalltalkMethodContext.prototype.locals = {};
+SmalltalkMethodContext.prototype.receiver = null;
+SmalltalkMethodContext.prototype.selector = null;
+SmalltalkMethodContext.prototype.lookupClass = null;
+
 inherits(SmalltalkMethodContext, SmalltalkObject);
 
 SmalltalkMethodContext.prototype.fill = function(receiver, selector, args, locals, lookupClass) {
@@ -742,11 +747,8 @@ SmalltalkMethodContext.prototype.fill = function(receiver, selector, args, local
 };
 
 SmalltalkMethodContext.prototype.fillBlock = function(args, locals) {
-    this.receiver    = null;
-    this.selector    = null;
     this.args        = args || [];
     this.locals      = locals || {};
-    this.lookupClass = null;
 };
 
 SmalltalkMethodContext.prototype.init = function() {