# HG changeset patch # User Mike Pavone # Date 1342319044 25200 # Node ID ba032565c7a58536c8cc18a296b278ec43404573 # Parent 3a169ebb3224d70f4d06a0cbdc48401b5d72ad89 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. diff -r 3a169ebb3224 -r ba032565c7a5 cbackend.js --- 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); } diff -r 3a169ebb3224 -r ba032565c7a5 samples/compilerbug_005.tp --- 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 } }