view scripttags.js @ 69:ba032565c7a5

Fix handling of variable style access to self and parent object messages defined with lambdas. Improve test case for this bug to include parent object access as well as self object access.
author Mike Pavone <pavone@retrodev.com>
date Sat, 14 Jul 2012 19:24:04 -0700
parents 4d87c38404d6
children 648659961e0e
line wrap: on
line source


function compileAndRun(src)
{
	var ast = parser.parse(src);
	var js = ast.toJSModule();
	mainModule = eval(js)();
	if (mainModule.strue) {
		each(mainModule.strue, function(key, val) {
			if(val instanceof Function) {
				Boolean.prototype[key] = function() {
					return this.valueOf() ? mainModule.strue[key].apply(mainModule.strue, arguments) : mainModule.sfalse[key].apply(mainModule.sfalse, arguments);
				};
			}
		});
	}
	mainModule.main();
}

onReady(function() {
	var tags = qall('script[type="text/tabletprog"]');
	for (var i = 0; i < tags.length; ++i) {
		if (tags[i].src) {
			get(tags[i].src, function(req) {
				compileAndRun(req.responseText);
			});
		} else {
			compileAndRun(tags[i].innerHTML);
		}
	}
});