# HG changeset patch # User Michael Pavone # Date 1427577664 25200 # Node ID 61f5b794d93931eecddb41b866389c931fcfe2e6 # Parent e70f9d3f19f891d3905cb0058c5f78fa31c6292d Breaking change: method call syntax now always uses the syntactic receiver as the actual receiver. This makes its behavior different from function call syntax, but solves some problems with methods being shadowed by local variables and the like. diff -r e70f9d3f19f8 -r 61f5b794d939 cbackend.js --- a/cbackend.js Sat Mar 28 13:26:44 2015 -0700 +++ b/cbackend.js Sat Mar 28 14:21:04 2015 -0700 @@ -227,39 +227,41 @@ return null; } var args = this.args.slice(0, this.args.length); + var method = false; + var start = 0; if (this.receiver) { args.splice(0, 0, this.receiver); - } - var method = false; - var funinfo = this.symbols.find(name); - var start = 0; - if (!funinfo || funinfo.def instanceof setter || funinfo.type == 'toplevel') { method = true; } else { - switch(funinfo.type) - { - case 'self': - case 'parent': - var defargs = funinfo.def.args.length; - if (!defargs || funinfo.def.args[0].cleanName() != 'self') { - defargs ++ + var funinfo = this.symbols.find(name); + if (!funinfo || funinfo.def instanceof setter || funinfo.type == 'toplevel') { + method = true; + } else { + switch(funinfo.type) + { + case 'self': + case 'parent': + var defargs = funinfo.def.args.length; + if (!defargs || funinfo.def.args[0].cleanName() != 'self') { + defargs ++ + } + if (args.length < defargs) { + if (funinfo.type == 'self') { + args.splice(0, 0, new symbol('self', this.symbols)); + } else { + var obj = (new symbol('self', this.symbols)).toC() + '->header.'; + for (var i = 0; i < funinfo.depth; ++i) { + obj += (i ? '->' : '') + 'parent'; + } + args.splice(0, 0, ', ' + obj); + start = 1; + } + } else if(!(args[0] instanceof symbol) || args[0].name != 'self') { + funinfo = null; + } + method = true; + break; } - if (args.length < defargs) { - if (funinfo.type == 'self') { - args.splice(0, 0, new symbol('self', this.symbols)); - } else { - var obj = (new symbol('self', this.symbols)).toC() + '->header.'; - for (var i = 0; i < funinfo.depth; ++i) { - obj += (i ? '->' : '') + 'parent'; - } - args.splice(0, 0, ', ' + obj); - start = 1; - } - } else if(!(args[0] instanceof symbol) || args[0].name != 'self') { - funinfo = null; - } - method = true; - break; } } for (var i = start; i < args.length; i++) {