Ver código fonte

late fn rebinding; cleaner solution to Error handling

Reverts fix from few days ago that has broken load/runtime
separation and fixes error handling by taking fn into account
when redefining classes, enabling later fn injecting.
Herbert Vojčík 10 anos atrás
pai
commit
8117d3ed7a
1 arquivos alterados com 37 adições e 32 exclusões
  1. 37 32
      support/boot.js

+ 37 - 32
support/boot.js

@@ -429,6 +429,11 @@ function ClassesBrik(brikz, st) {
 //            st[className].superclass = superclass;
 			st[className].iVarNames = iVarNames || [];
 			if (pkg) st[className].pkg = pkg;
+			if (fn) {
+				fn.prototype = st[className].fn.prototype;
+				st[className].fn = fn;
+				fn.prototype.constructor = fn;
+			}
 		} else {
 			if(st[className]) {
 				st.removeClass(st[className]);
@@ -798,47 +803,47 @@ function RuntimeBrik(brikz, st) {
 		this.pc          = 0;
 	}
 
-// Fallbacks
-	SmalltalkMethodContext.prototype.locals = {};
-	SmalltalkMethodContext.prototype.receiver = null;
-	SmalltalkMethodContext.prototype.selector = null;
-	SmalltalkMethodContext.prototype.lookupClass = null;
-
 	inherits(SmalltalkMethodContext, SmalltalkObject);
 
 	this.__init__ = function () {
 		st.wrapClassName("MethodContext", "Kernel-Methods", SmalltalkMethodContext, st.Object, false);
-	};
 
-	SmalltalkMethodContext.prototype.fill = function(receiver, selector, locals, lookupClass) {
-		this.receiver    = receiver;
-		this.selector    = selector;
-		this.locals      = locals || {};
-		this.lookupClass = lookupClass;
-	};
+		// Fallbacks
+		SmalltalkMethodContext.prototype.locals = {};
+		SmalltalkMethodContext.prototype.receiver = null;
+		SmalltalkMethodContext.prototype.selector = null;
+		SmalltalkMethodContext.prototype.lookupClass = null;
+
+		SmalltalkMethodContext.prototype.fill = function(receiver, selector, locals, lookupClass) {
+			this.receiver    = receiver;
+			this.selector    = selector;
+			this.locals      = locals || {};
+			this.lookupClass = lookupClass;
+		};
 
-	SmalltalkMethodContext.prototype.fillBlock = function(locals, ctx) {
-		this.locals        = locals || {};
-		this.outerContext  = ctx;
-	};
+		SmalltalkMethodContext.prototype.fillBlock = function(locals, ctx) {
+			this.locals        = locals || {};
+			this.outerContext  = ctx;
+		};
 
-	SmalltalkMethodContext.prototype.init = function() {
-		var home = this.homeContext;
-		if(home) {
-			home.init();
-		}
+		SmalltalkMethodContext.prototype.init = function() {
+			var home = this.homeContext;
+			if(home) {
+				home.init();
+			}
 
-		this.setup(this);
-	};
+			this.setup(this);
+		};
 
-	SmalltalkMethodContext.prototype.method = function() {
-		var method;
-		var lookup = this.lookupClass || this.receiver.klass;
-		while(!method && lookup) {
-			method = lookup.methods[st.convertSelector(this.selector)];
-			lookup = lookup.superclass;
-		}
-		return method;
+		SmalltalkMethodContext.prototype.method = function() {
+			var method;
+			var lookup = this.lookupClass || this.receiver.klass;
+			while(!method && lookup) {
+				method = lookup.methods[st.convertSelector(this.selector)];
+				lookup = lookup.superclass;
+			}
+			return method;
+		};
 	};
 
 	/* This is the current call context object. While it is publicly available,