changeset 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 3a169ebb3224
children 0efd25a4958a
files cbackend.js samples/compilerbug_005.tp
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cbackend.js	Sat Jul 14 16:14:01 2012 -0700
+++ b/cbackend.js	Sat Jul 14 19:24:04 2012 -0700
@@ -96,8 +96,15 @@
 		throw new Error('symbol ' + name + ' not found');
 	}
 	if (info.type == 'toplevel') {
-		
 		return toplevel.moduleVar(name);
+	} else if (info.type == 'self' && info.def instanceof lambda) {
+		return 'mcall(' + getMethodId(name) + '/* ' + name + ' */, 1, ' + (new symbol('self', this.symbols)).toC() + ')';
+	} else if (info.type == 'parent' && info.def instanceof lambda) {
+		var obj = (new symbol('self', this.symbols)).toC() + '->header.';
+		for (var i = 0; i < info.depth; ++i) {
+			obj += (i ? '->' : '') + 'parent';
+		}
+		return 'mcall(' + getMethodId(name) + '/* ' + name + ' */, 1, ' + obj + ')';
 	}
 	return getSymbolPrefix(info, this.symbols) + escapeCName(name);
 }
--- a/samples/compilerbug_005.tp	Sat Jul 14 16:14:01 2012 -0700
+++ b/samples/compilerbug_005.tp	Sat Jul 14 19:24:04 2012 -0700
@@ -1,6 +1,12 @@
 #{
 	foo <- { "foobar" }
+	bar <- #{
+		baz <- {
+			print: foo
+		}
+	}
 	main <- {
 		print: foo
+		bar baz
 	}
 }